在一行代码中从十个文本文件(或多个文本文件)中读取?

时间:2016-10-31 03:01:25

标签: java histogram file-handling

所以我试图同时阅读十个文本文件,我的目标是缩短代码。有没有办法从一行代码中编码?因为我想要更短的代码/方式。这是我的代码:

while (((a = First.readLine()) != null) || (a = Second.readLine()) != null)

P.S。我编码直方图......

1 个答案:

答案 0 :(得分:0)

您需要获取包含所有档案的文件夹的dirPath。

Files.walk(Paths.get(dirPath)).forEach(filePath -> {readArchive(filePath);});