1import java.io.*;
2public class CopyFile {
3
4 public static void main(String args[]) throws IOException {
5 FileInputStream in = null;
6 FileOutputStream out = null;
7
8 try {
9 in = new FileInputStream("input.txt");
10 out = new FileOutputStream("output.txt");
11
12 int c;
13 while ((c = in.read()) != -1) {
14 out.write(c);
15 }
16 }finally {
17 if (in != null) {
18 in.close();
19 }
20 if (out != null) {
21 out.close();
22 }
23 }
24 }
25}
1Arrays.asList("a1", "a2", "a3")
2 .stream()
3 .findFirst()
4 .ifPresent(System.out::println); // a1
5