Hi folks,
I have a process that needs to read lots of large UTF-8 files. I am finding a way to speed up the read process. I use the traditional way to read because the BufferedReader provides me the readLine() function so I do not need to parse the carriage return.
BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(file), BzFileUtil.UTF8));
String line;
while ((line = in.readLine()) != null) {
......
}
in.close();
If I want to use Channel, I will lose the readLine(). I found I can create the BufferedReader with Channel, so iI test it. Howerver, I do not notice it makes any faster.
ReadableByteChannel in = new FileInputStream(file).getChannel();
BufferedReader reader=new BufferedReader(Channels.newReader(in, "UTF-8"));
String line;
while ((line = reader.readLine()) != null) {
....
}
reader.close();
Would anyone tell me how I could use the Channel to read lines in the UTF-8 files? Any input will helps, thanks!