如何修改 正确关闭文件流?
package zh.codegym.task.task18.task1818;
import java.io.*;
/*
合二为一
*/
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String file1 = reader.readLine();
String file2 = reader.readLine();
String file3 = reader.readLine();
reader.close();
FileInputStream f2 = new FileInputStream(file2);
FileOutputStream f1 = new FileOutputStream(file1);
FileInputStream f3 = new FileInputStream(file3);
byte[] buffer2 = new byte[f2.available()];
int count2 = f2.read(buffer2);
f2.close();
f1.write(buffer2,0,count2);
byte[] buffer3 = new byte[f3.available()];
int count3 = f3.read(buffer3);
f3.close();
f1.write(buffer3,0,count3);
f1.close();
}
}