OnJava8-Examples/files/StreamInAndOut.java

25 lines
672 B
Java
Raw Permalink Normal View History

2015-12-06 11:45:16 -08:00
// files/StreamInAndOut.java
// (c)2021 MindView LLC: see Copyright.txt
2015-12-06 11:45:16 -08:00
// We make no guarantees that this code is fit for any purpose.
2016-09-23 13:23:35 -06:00
// Visit http://OnJava8.com for more book information.
2015-12-06 11:45:16 -08:00
import java.io.*;
import java.nio.file.*;
import java.util.stream.*;
public class StreamInAndOut {
public static void main(String[] args) {
try(
Stream<String> input =
Files.lines(Paths.get("StreamInAndOut.java"));
PrintWriter output =
new PrintWriter("StreamInAndOut.txt")
) {
2015-12-06 11:45:16 -08:00
input
.map(String::toUpperCase)
.forEachOrdered(output::println);
} catch(Exception e) {
throw new RuntimeException(e);
}
}
}