我还是 Java 的新手,尤其是供应商的新手,但我不知道为什么我无法从以下代码中获得任何输出:
final BufferedReader brLines = new BufferedReader(new InputStreamReader(csvFile));
final Supplier<Stream<LinkedList<String>>> procLines = () -> brLines.lines().map(elm -> processCSV(elm));
lineCount = Math.toIntExact(procLines.get().count());
System.out.println(lineCount); // This prints the correct amount of lines to the console.
final CountDownLatch latch = new CountDownLatch(lineCount);
Stream<LinkedList<String>> listStream = procLines.get();
listStream.forEach((x) -> {
System.out.println(x); // Why is there no console output here?
outputText(() -> x); // Why is there no console output here either?
...
});
以下是此块中提到的一些方法
public static LinkedList<String> processCSV(String line) {
LinkedList<String> elms = new LinkedList<String>();
char delimiter = ',';
char quote = '"';
String[] elmArray = splitCSVWithQuote(line, delimiter, quote).toArray(new String[0]);
for (String elm : elmArray) {
elms.add(elm);
}
return elms;
}
&
public static void outputText(Supplier sup) {
System.out.println(sup.get());
}
任何人都可以提供任何帮助吗?