About Question enthuware.ocpjp.v8.2.1157 :
Posted: Fri Apr 07, 2023 2:02 pm
Why is the write method called here before the close method and therefore does not throw an exception?
Code: Select all
public class Test {
public static void main(String[] args) {
try(PrintWriter bw = new PrintWriter("F:\\test.txt"))
{
bw.close();
bw.write(1);
} catch(IOException e) {
System.out.println("IOException");
}
}
}