Привет,
в чём может быть ошибка?
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
public class Main {
public static void main(String...args) {
TryResoursesDemo.copyFile("fileFrom", "fileTo");
}
}
class TryResoursesDemo {
public static void copyFile(String fileFrom, String fileTo) throws IOException {
try (FileInputStream fin = new FileInputStream(fileFrom);
FileOutputStream fout = new FileOutputStream(fileTo);
) {
int ch;
while ((ch = fin.read()) != -1) {
fout.write(ch);
}
System.out.println("file has been copyied.");
} catch (IOException e) {
e.printStackTrace();
}
}
}
Error:(7, 34) java: unreported exception java.io.IOException; must be caught or declared to be thrown