[英]Can someone tell me a different way of writing this line of code?
I know this is a strange question but for research purposes could anyone tell me a different way of writing this line of code? 我知道这是一个奇怪的问题,但是出于研究目的,有人可以告诉我另一种编写此代码行的方式吗? I am making a word cloud in The "forEach(s -> ignoreWords.add(s.toUpperCase()));" 我在“ forEach(s-> ignoreWords.add(s.toUpperCase()));”中制作词云 is the line of code I would like to change. 是我要更改的代码行。 Preferably not a lambda 最好不是lambda
Thanks very much in advance!!!! 首先十分感谢!!!!
Researched numerous pages 研究了无数页
BufferedReader br = new BufferedReader(new InputStreamReader(input));
ignoreWords = new HashSet<String>();
Stream<String> stream = Files.lines(Paths.get("/ignorewords.txt"));
stream.forEach(s -> ignoreWords.add(s.toUpperCase()));
Will this work? 这样行吗?
Set<String> ignoreWords = Files.lines(Paths.get("/ignorewords.txt"))
.map(String::toUpperCase)
.collect(Collectors.toSet())
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.