Solved

re-read a file

Posted on 2006-11-02
2
270 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
ID: 17860952
See BufferedReader.mark and BufferedReader.reset
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 17861798
:-)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
mapAB Challlenge 35 126
topping1 challenge 7 73
Image decoding from Camera 3 72
netstat -ano | find "8000" and taskkill /f /pid 2984 3 33
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

910 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

20 Experts available now in Live!

Get 1:1 Help Now