如何将代码转换为7行流? [关闭]

我需要更改代码才能流式传输。应该只有7行代码。

  1. Use Files.lines() to read file as stream
  2. Filter out lines which are not matching pattern "only whitespaces and numbers"
  3. Use map operation which will inside split the line by whitespace and convert that to stream (Arrays.stream() can be useful, then use reduce operation to get numbers concatenated with "+", then use the same trick as above to calculate the sum of numbers and concatenate it with above string)
  4. Write each line to a file - just using PrintWriter and forEach or use Files.write() method