Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

close and reopen the bufferedreader

 
Kowshik Nandagudi
Ranch Hand
Posts: 57
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20665
65
Chrome Eclipse IDE Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to create a new FileReader or FileInputStream, and wrap it as usual.
 
Kowshik Nandagudi
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13074
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 50211
79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic