Solved

re-read a file

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

Expert Comment

by:CEHJ
ID: 17861798
:-)
0

Featured Post

Technology Partners: 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

Suggested Solutions

Title # Comments Views Activity
java mysql insert application 14 47
passing enum to a method 4 37
Given a github repo find email address of all collaborators in that repo 1 36
Java array 10 65
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

730 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