我必须在 JAVA 中编写如下结构的代码:
Read String From File
// Perform some string processing
Write output string in file
现在,为了从文件中读取/写入字符串,我正在使用,
BufferedReader br = new BufferedReader(new FileReader("Text.txt"), 32768);
BufferedWriter out = new BufferedWriter(new FileWriter("AnotherText.txt"), 32768);
while((line = br.readLine()) != null) {
//perform some string processing
out.write(output string) ;
out.newLine();
}
但是,阅读和写作似乎很慢。有没有其他最快的方法可以在 JAVA 文件中读取/写入字符串?
附加信息:
1) Read File is 144 MB.
2) I can allocate large memory (50 MB) for reading or writing.
3)I have to write it as a string, not as Byte.