Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Plug-in with file(s)
Plug-in with file(s) [message #289390] Thu, 04 August 2005 11:08 Go to next message
Eclipse UserFriend
Originally posted by: callum.devnet-uk.net

My plug-in gets some data (just plain ascii chars) from a file. I have a
added these the build path and when I run I can read the file contents
like this:

URL url = Platform.getBundle ("BundleName").getEntry ("path to file") ;

InputStream in = url.openStream() ;
int i ;
while ((i =in.read()) != -1)
System.out.print ((char)i) ;

if (in !=null) in.close () ;

Now, this is "ok", but is there a more friendly way of this doing, such as
grabbing a line at a time?

I tried to use other stream classes, such a FileReader, etc but when
trying to open the file it always says it can't find it. Am I stuck with
this method?
Re: Plug-in with file(s) [message #289394 is a reply to message #289390] Thu, 04 August 2005 11:45 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Callum Urquhart wrote:
>
> My plug-in gets some data (just plain ascii chars) from a file. I have a
> added these the build path and when I run I can read the file contents
> like this:
>
> URL url = Platform.getBundle ("BundleName").getEntry ("path to file") ;
>
> InputStream in = url.openStream() ;
> int i ;
> while ((i =in.read()) != -1)
> System.out.print ((char)i) ;
>
> if (in !=null) in.close () ;
>
> Now, this is "ok", but is there a more friendly way of this doing, such
> as grabbing a line at a time?
>
> I tried to use other stream classes, such a FileReader, etc but when
> trying to open the file it always says it can't find it. Am I stuck with
> this method?

You just need to wrap your InputStream in a bridge:
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
String line = null;
while ((line = reader.readLine())!=null) {
....
}

Later,
PW


Re: Plug-in with file(s) [message #289402 is a reply to message #289394] Thu, 04 August 2005 12:02 Go to previous message
Eclipse UserFriend
Originally posted by: callum.devnet-uk.net

Yip, I've got it.

Thanks.
Previous Topic:Proposal of multi-autoGathered Plugin.inc.xml files
Next Topic:Editor
Goto Forum:
  


Current Time: Fri Mar 29 01:40:36 GMT 2024

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

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

Back to the top