Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » FileInputStream and IFile
FileInputStream and IFile [message #326570] Tue, 25 March 2008 13:26 Go to next message
Eclipse UserFriend
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 messageGo to next message
Eclipse UserFriend
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 messageGo to next message
Eclipse UserFriend
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 #326573 is a reply to message #326571] Tue, 25 March 2008 13:47 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: alexjaquet.gmail.com

finally founded FileInputStream fis = new
FileInputStream(file.getLocation().toString());
Re: FileInputStream and IFile [message #326574 is a reply to message #326573] Tue, 25 March 2008 14:48 Go to previous messageGo to next message
Eclipse UserFriend
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());
Re: FileInputStream and IFile [message #326575 is a reply to message #326574] Tue, 25 March 2008 15:17 Go to previous message
Eclipse UserFriend
Originally posted by: alexjaquet.gmail.com

Ok thanks for your suggestion I will change that :)

Regards

Alexandre
Previous Topic:CompareEditor ; StructureInputPane
Next Topic:[DataBinding] Date conversion
Goto Forum:
  


Current Time: Sat Nov 09 05:22:19 GMT 2024

Powered by FUDForum. Page generated in 0.03251 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top