Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Stream a file
Stream a file [message #288185] Wed, 13 July 2005 09:58 Go to next message
Eclipse UserFriend
Originally posted by: andreas140983.libero.it

Hi, I want to obtain the content of a file in a plugin and insert it in a
String. I have already write this code:
IFile file2=container.getFile(new Path("config.txt"));
if (file2.exists()) {
InputStream stream1= file2.getContents();

But now what I have to write?
Please help me!

Andrea
Re: Stream a file [message #288199 is a reply to message #288185] Wed, 13 July 2005 11:20 Go to previous message
Eclipse UserFriend
Andrea Sichel wrote:
> Hi, I want to obtain the content of a file in a plugin and insert it in
> a String. I have already write this code:
> IFile file2=container.getFile(new Path("config.txt"));
> if (file2.exists()) {
> InputStream stream1= file2.getContents();
>
> But now what I have to write? Please help me!
>
> Andrea
>

This is live code, so it may have some compile problems. Nevertheless,
it should give you a good idea of what to do.


BufferedReader br =
new BufferedReader(new InputStreamReader(file2.getContents()));
StringBuffer contents = new StringBuffer();
String line = null;

while ((line = br.readLine()) != null)
contents.append(line);

System.out.println(contents.toString());

// be sure to wrap things in a try/catch/finally block
// and close your stream in the finally
Previous Topic:Anyone written their own search integrated with the search view?
Next Topic:package org.osgi.service.condpermadmin missing in OSGi-Specification
Goto Forum:
  


Current Time: Sun Jul 27 18:45:50 EDT 2025

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

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

Back to the top