Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Problem with Reading very long line using bufferedReader  RSS feed

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,
 
Rancher
Posts: 4686
7
Linux Mac OS X VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Problem is just because of i forgot to close FileWriter object.....
Now its working correctly....
Thanks for your Suggestions...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!