About Question enthuware.ocpjp.v8.2.1202 :
Posted: Fri Oct 07, 2016 7:19 am
I don't understand who could throw the java.io.InvalidClassException ?
My first impression was that nobody can throw this exception and I answered it was a compilation error.
Code: Select all
public static void copy(String records1, String records2) throws IOException {
try (InputStream is = new FileInputStream(records1);
OutputStream os = new FileOutputStream(records2);) {
byte[] buffer = new byte[1024];
int bytesRead = 0;
while ((bytesRead = is.read(buffer)) != -1) {
os.write(buffer, 0, bytesRead);
}
} catch (FileNotFoundException | java.io.InvalidClassException e) {
e.printStackTrace();
}
}