开发者

Partial reading of file in Java

I am creating a Java application in which I need to read the first few lines of a huge text file and do the processing. Is it possible that i开发者_如何学Gonstead of getting the entire file, I read the first few lines and fetch the data? And this is being done using Java API.


Use BufferedReader.


Yes, it can be done. When you use BufferedReader, for example, you read just (buffer_size) from the file. Then you can process it before reading the next fragment...

for example, see this tutorial


There is also LineNumberReader if you need to keep track of the line numbers

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜