什么是每行读取线路的最快方式 [英] Whats the fastest way to read line per line

查看:153
本文介绍了什么是每行读取线路的最快方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个巨大的文件与字符串。所有行都应该添加到我的代码中的List中。什么是最快的方式?我发现这个但我不知道如何使用它来读取每行的行数。

i have a huge file with Strings. All of the lines should be added to a List in my code. Whats the fastest way to do this? i found this but i dont know how to use it to read line per line.

推荐答案

我怀疑内置的解决方案应该足够快:

I suspect that the built-in solution should be fast enough:

List<String> allLines = Files.readAllLines(Paths.get("location/of/your/file"));

(假设你的JVM有足够的内存)

(assuming your JVM has enough memory)

这篇关于什么是每行读取线路的最快方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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