读取一个2G的文件,发生错误:
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Arrays.java:2760)
at java.util.Arrays.copyOf(Arrays.java:2734)
at java.util.ArrayList.ensureCapacity(ArrayList.java:167)
at java.util.ArrayList.add(ArrayList.java:351)
at org.apache.commons.io.IOUtils.readLines(IOUtils.java:504)
at org.apache.commons.io.IOUtils.readLines(IOUtils.java:457)
at com.sany.client.test.QzjTemp.main(QzjTemp.java:38)
读取方法是:
String path=JOptionPane.showInputDialog(null,"请输入路径:");
File filePATH = new File(path);
List<String> lines = IOUtils.readLines(new FileInputStream(filePATH));
在最后一句List<String> lines = IOUtils.readLines(new FileInputStream(filePATH)); 出错。
文件是一个***.log文件