?
Solved

re-read a file

Posted on 2006-11-02
2
Medium Priority
?
278 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 500 total points
ID: 17860952
See BufferedReader.mark and BufferedReader.reset
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 17861798
:-)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Suggested Courses
Course of the Month12 days, 17 hours left to enroll

777 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