List of utility methods to do Stream Close
Throwable | close(final OutputStream dest) close if (dest != null) { try { dest.close(); } catch (final Throwable t) { return t; return null; ... |
void | close(final Scanner scanner) close if (scanner != null) {
scanner.close();
|
void | close(Iterator> iterator) Checks if the provided iterator implements Closeable . if (iterator != null && iterator instanceof Closeable) { try { ((Closeable) iterator).close(); } catch (IOException e) { String name = iterator.getClass().getPackage().toString(); Logger log = Logger.getLogger(name); log.log(Level.FINE, e.getMessage(), e); |
void | close(java.io.Closeable in) Closes a stream, handling all exceptions if (in == null) return; try { in.close(); } catch (Exception e) { |
void | close(JMXConnector connector) close if (connector != null) { try { connector.close(); } catch (IOException e) { e.printStackTrace(); |
void | close(Object obj) close if (obj == null) return; try { if (obj instanceof InputStream) ((InputStream) obj).close(); else if (obj instanceof ZipFile) ((ZipFile) obj).close(); else if (obj instanceof OutputStream) ... |
void | close(Object resource) Closes the streams and resources. try { if (resource instanceof InputStream) { ((InputStream) resource).close(); } else if (resource instanceof OutputStream) { ((OutputStream) resource).close(); } else if (resource instanceof Reader) { ((Reader) resource).close(); } else if (resource instanceof Writer) { ... |
void | close(ObjectInput in) close try { if (in != null) { in.close(); } catch (Exception ex) { |
void | close(OutputStream in) Just a convenience method to avoid littering code with if's and catches try { if (in != null) { in.close(); } catch (Exception e) { e.printStackTrace(); |
void | close(OutputStream os) Close output streams that are not print streams. if (!(os instanceof PrintStream)) { os.close(); |