Solved

re-read a file

Posted on 2006-11-02
2
268 Views
Last Modified: 2008-03-10
Hi all:

I want to open a file on the web site, copy the file to my pc, and then, read it again to do something else. Now my question is: is there anyway I can re-open the web file to read it again without having to re-declare all those streams, readers, etc.? My code is like the following:

URL u = new URL(webFilePath + fileName);
InputStream in = u.openStream();            
in = new BufferedInputStream(in);
Reader isr = new InputStreamReader(in);
BufferedReader br = new BufferedReader(isr);

//copy the file
....
br.close();

//read the file again, this time parse the line read and do something
??

Is there any way I can avoid re-declaring everything? It's no big deal to do that, but if there're smarter way to do things, I want to know.

Thanks.
0
Comment
Question by:sdc248
  • 2
2 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 125 total points
Comment Utility
See BufferedReader.mark and BufferedReader.reset
0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
:-)
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
The viewer will learn how to implement Singleton Design Pattern in Java.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now