且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

扫描仪读取大文件

更新时间:2023-01-11 19:19:41

这个问题通常比较常见在64位计算机上或使用大小超过1-2 GB的文件,并且与堆空间无关。切换到BufferedReader它应该可以正常工作,

This issue is usually more common on 64 bit machines or with files having size more than 1-2 GB and does not have anything to do with heap space. Switch to BufferedReader it should work fine,

BufferedReader br = new BufferedReader(new FileReader(filepath));
String line = "";
while((line=br.readLine())!=null)
{
    // do something
}