• No replies
1 Post

Pinned topic Manipulating text file with NIO?

‏2010-02-17T08:10:16Z |

I want to find a replace some texts in every line of a large text file (at least 8GB).

With the standard IO, I could loop through every line using BufferedReader's readLine() and then manipulate the line using regular expression. Unfortunately, this is going to take a very long time to process a 8GB file.

I guess the Java NIO can rescue in this case, right? However, unlike BufferedReader, the FileChannel actually deals with ByteBuffer. May I know how to manipulate every line of a text file in Java NIO?

Appreciate if you could point me some examples too!

Thank you!