The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
December 2001

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

How big is each line?

Posted by Hiran on December 26, 2001 at 2:42 PM

Bhargav, how big is each line that it is too big for rec? Also, a tip: instead of creating a File object, and a FileReader object, you can just write BufferedReader br = new BufferedReader(new FileReader(new File("test.txt"))) unless you need to use some of the functions of File or FileReader later on. In regard to your problem, you could try reading in each line character by character until you hit the end of line character and then read from the next line the same way. You could then use an array to store the variables, or use a Vector. There probably is a better solution, but that's all I can think of. Any other ideas, anyone?
Hiran

> hello ...i am reading a text file using readLine() but the record which i am reading is very large for the string variable in which i am populating it. and hence at theend itis giving me exception.
> my code is like...

> File f = new File("Test.txt");
> FileReader fr = new FileReader(f);
> BufferedReader br = new BufferedReader(fr);
> String rec;

> while((rec = br.readLine()) != null)
> {
> //some code goes here
> }

> itis unable to corporate the whole record in variable "rec"
> so what should i do as i have to extract certain data from this record using "substring()" function...
> pls help ..it is urgent..
> thanking u..
> bhargav...





Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us