• Post Reply Bookmark Topic Watch Topic
  • New Topic

how read in Large Text files (10 mb)?  RSS feed

 
chibi riko
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how read in Large Text files(10 mb) Java?
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

The standard FileReader class, which is used to read smaller text files too, should have no issues with 10 megabyte text files.

Henry
 
Campbell Ritchie
Marshal
Posts: 56546
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In Java8, you can read it one line at a time. Wrap your file reader in a buffered reader and use its lines() method to get a Stream<String>. Since Streams run by lazy execution, you are only handling one String at a time.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!