FileInputStream and IFile [message #326570] |
Tue, 25 March 2008 13:26 ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Eclipse User![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=) |
|
|
|
Originally posted by: alexjaquet.gmail.com
Hi,
I'm looking for a way to create FileInputStream within an IFile,
i've tryed to create it with
private void initializeContents(IFile file) {
try {
FileInputStream fis = new
FileInputStream(file.getFullPath().toString());
BufferedReader myInput = new BufferedReader (new InputStreamReader(fis));
String thisLine = null;
StringBuffer buffer = new StringBuffer();
while ((thisLine = myInput.readLine()) != null) {
System.out.println(thisLine);
buffer.append(thisLine);
}
myInput.close();
setContents(buffer.toString());
} catch (Exception e) {
e.printStackTrace();
}
but the file.getFullPath doesn't give the absolut full path
How can I deal with it
Thanks
Alexandre
|
|
|
Re: FileInputStream and IFile [message #326571 is a reply to message #326570] |
Tue, 25 March 2008 13:34 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Eclipse User![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=) |
|
|
|
Originally posted by: alexjaquet.gmail.com
the method System.out.println("Project path " +
ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSS tring() );
return my the junit-workspace
|
|
|
Re: FileInputStream and IFile [message #326572 is a reply to message #326570] |
Tue, 25 March 2008 13:42 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Eclipse User![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=) |
|
|
|
Originally posted by: valere.fedronic.ext.streamezzo.com
Why don't you use the getContent() method?
InputStream fis = file.getContents();
Valère.
Alexandre Jaquet a écrit :
> Hi,
>
> I'm looking for a way to create FileInputStream within an IFile,
>
> i've tryed to create it with
>
> private void initializeContents(IFile file) {
> try {
> FileInputStream fis = new
> FileInputStream(file.getFullPath().toString());
> BufferedReader myInput = new BufferedReader (new
> InputStreamReader(fis));
> String thisLine = null;
> StringBuffer buffer = new StringBuffer();
> while ((thisLine = myInput.readLine()) != null) {
> System.out.println(thisLine);
> buffer.append(thisLine);
> }
> myInput.close();
> setContents(buffer.toString());
> } catch (Exception e) {
> e.printStackTrace();
> }
>
> but the file.getFullPath doesn't give the absolut full path
>
> How can I deal with it
>
> Thanks
>
> Alexandre
|
|
|
|
Re: FileInputStream and IFile [message #326574 is a reply to message #326573] |
Tue, 25 March 2008 14:48 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Eclipse User![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=) |
|
|
|
Originally posted by: merks.ca.ibm.com
Alexandre,
This is still a bad idea. Why not follow the other advice that was
given? Why is it so important to access the underlying file directly?
Given that EFS supports non-file-based locations, your approach here
isn't fully general...
Alexandre Jaquet wrote:
> finally founded FileInputStream fis = new
> FileInputStream(file.getLocation().toString());
|
|
|
|
Powered by
FUDForum. Page generated in 0.04005 seconds