This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Servlets and the fly likes Problem with Reading very long line using bufferedReader Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Problem with Reading very long line using bufferedReader" Watch "Problem with Reading very long line using bufferedReader" New topic
Author

Problem with Reading very long line using bufferedReader

Nikul Prajapati
Greenhorn

Joined: Sep 10, 2011
Posts: 7
I am reading file line by line using bufferedReader in java.
My file contains very long lines (about 913434 characters per line).

FileInputStream inStream=new FileInputStream(inFile);
DataInputStream inDataStream=new DataInputStream(inStream);
BufferedReader br=new BufferedReader(new InputStreamReader(inDataStream));

String str=null;
while ((str = br.readLine()) !=null){
System.out.println(str);
}

But it's always give some portion of line . It's failed to read whole line.
Please , help me on How to read whole line ?

Thanks,
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4646
    
    5

How do you know that its failing?

Why are you trying to call System.out.println() on a million character line?

How about doing a simpler, more sane test, such as printing out

System.out.println(str.size());
Nikul Prajapati
Greenhorn

Joined: Sep 10, 2011
Posts: 7
Problem is just because of i forgot to close FileWriter object.....
Now its working correctly....
Thanks for your Suggestions...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem with Reading very long line using bufferedReader
 
Similar Threads
readUTF not working
IO Questions
Skip Reading several Lines using BufferedReader
File Deletion, and problems with overwriting instead of adding to file.
BufferedReader.readLine() skips lines