aspose file tools*
The moose likes Java in General and the fly likes close and reopen the bufferedreader Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "close and reopen the bufferedreader" Watch "close and reopen the bufferedreader" New topic
Author

close and reopen the bufferedreader

Kowshik Nandagudi
Ranch Hand

Joined: Dec 09, 2010
Posts: 57
I am reading a large file using bufferedreaderI am closing the file and then how do i reopen the file??

bufferedReader.close();

THen how do i reopen the file???

what is the method i need to use for reopening the file??
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19760
    
  20

You need to create a new FileReader or FileInputStream, and wrap it as usual.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Kowshik Nandagudi
Ranch Hand

Joined: Dec 09, 2010
Posts: 57
thanks Rob. But is there anyway I can read the entire file into the memory and use that??

What should be the approach for reading a large file my file is 100 MB text file
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12823
    
    5
The following questions occur:

1. How much of the file do you need in memory at any one time to do whatever it is you are trying to do?
2. Is the file in plain ASCII or what?
3. Why are you closing the reader at all?

Bill
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39805
    
  28
Kowshik Nandagudi wrote: . . . But is there anyway I can read the entire file into the memory and use that?? . . .
You can add the file to a List<String>, but careful in case you run out of memory. You can analyse the file and put its contents into a database, and use JDBC calls to retrieve what you need.

There are bound to be lots of other ways to do that.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: close and reopen the bufferedreader