= null) {
os = openOutputStream();
} catch (Exception e) {
\\ Handle exception
}
And be safe about the resource being closed?
I think yes, but need a little bit change like this: try (OutputStream stream = new ...) { ... // use the resource } catch (IOException e) { ... // exception handling code } More information about it: https://www.baeldung.com/java-try-with-resources
Обсуждают сегодня