用内存高效的方式在Java中读取一个庞大的数字文件? [英] Read a huge file of numbers in Java in a memory-efficient way?

查看:123
本文介绍了用内存高效的方式在Java中读取一个庞大的数字文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Java 中,如果文件 335Gb 大小,每行包含个别数字,我需要阅读它是逐行的,如果它是一个数字流 - 我不能将所有数据保存在内存中。我被告知 Scanner 类不起作用。你能否推荐一种最好的方法来做到这一点?

In Java, having a file of 335Gb size that contains individual numbers at each line, I need to read it line by line like if it was a stream of numbers - I must not keep all the data in memory. I was told that Scanner class will not work. Could you please recommend the best possible way to do that?

推荐答案

所有java.io输入流类都没有全部保留内存中的数据。我认为你可以自由选择最适合你的东西,比如BufferedReader或DataInputStream等。

None of the java.io input stream classes would "keep all the data in memory". I think you are free to choose what is best for you such as BufferedReader or DataInputStream etc.

这篇关于用内存高效的方式在Java中读取一个庞大的数字文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆