2015-12-06 11:45:16 -08:00
|
|
|
// files/StreamInAndOut.java
|
2021-01-31 15:42:31 -07:00
|
|
|
// (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) {
|
2016-09-06 12:32:51 -06:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|