java io

Solutions on MaxInterview for java io by the best coders in the world

showing results for - "java io"
Dustin
10 Jan 2021
1        FileInputStream in = null;
2        FileOutputStream out = null;
3
4        try {
5            in = new FileInputStream("input.txt");
6            out = new FileOutputStream("out.txt");
7            int c;
8
9            while ((c = in.read()) != -1) {
10                out.write(c);
11            }
12        } finally {
13            if (in != null) {
14                in.close();
15            }
16            if (out != null) {
17                out.close();
18            }
19        }