import javax.naming.NamingException;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.channels.ClosedChannelException;
import java.rmi.activation.ActivationException;
import java.util.Arrays;
public class Main{
try {
try(
DummyIO dummy = new DummyIO(false,true); //-- try with different true, false values
){
System.
out.
println("Inner: Caught: " + e1
); System.
out.
println("Inner: suppressed: " + Arrays.
toString(e1.
getSuppressed())); }finally {
}
System.
out.
println("Outer: Caught: " + e2
); System.
out.
println("Outer: suppressed: " + Arrays.
toString(e2.
getSuppressed())); }
}
private static class DummyIO implements AutoCloseable{
private boolean throwInClose;
if(throwInConstructor){
}
this.throwInClose = throwInClose;
}
@Override
if(throwInClose){
throw new ClosedChannelException();
}
}
}
}
aW1wb3J0IGphdmF4Lm5hbWluZy5OYW1pbmdFeGNlcHRpb247CmltcG9ydCBqYXZhLmlvLkZpbGVOb3RGb3VuZEV4Y2VwdGlvbjsKaW1wb3J0IGphdmEuaW8uSU9FeGNlcHRpb247CmltcG9ydCBqYXZhLm5pby5jaGFubmVscy5DbG9zZWRDaGFubmVsRXhjZXB0aW9uOwppbXBvcnQgamF2YS5ybWkuYWN0aXZhdGlvbi5BY3RpdmF0aW9uRXhjZXB0aW9uOwppbXBvcnQgamF2YS51dGlsLkFycmF5czsKCnB1YmxpYyBjbGFzcyBNYWluewoKICAgIHB1YmxpYyBzdGF0aWMgdm9pZCBtYWluKFN0cmluZ1tdIGFyZ3MpIHRocm93cyBOYW1pbmdFeGNlcHRpb24gewogICAgICAgIHRyeSB7CgoKICAgICAgICAgICAgdHJ5KAogICAgICAgICAgICAgICAgICAgIER1bW15SU8gZHVtbXkgPSBuZXcgRHVtbXlJTyhmYWxzZSx0cnVlKTsgLy8tLSB0cnkgd2l0aCBkaWZmZXJlbnQgdHJ1ZSwgZmFsc2UgdmFsdWVzCiAgICAgICAgICAgICl7CiAgICAgICAgICAgICAgICB0aHJvdyBuZXcgQWN0aXZhdGlvbkV4Y2VwdGlvbigpOwogICAgICAgICAgICB9IGNhdGNoIChJT0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