List of usage examples for java.io Closeable close
public void close() throws IOException;
From source file:Main.java
public static void close(Closeable closeable) { if (closeable != null) { try {/* w ww.j a v a 2 s . c o m*/ closeable.close(); } catch (IOException e) { throw new RuntimeException("IOException occurred. ", e); } } }
From source file:Main.java
public static boolean close(Closeable closeable) { if (closeable != null) { try {//from w w w.ja va2 s . com closeable.close(); return true; } catch (IOException e) { return false; } } else { return false; } }
From source file:Main.java
/** * Close a {@link Closeable} stream without throwing any exception * /*from w w w .ja v a 2 s. c o m*/ * @param c */ public static void closeSilently(final Closeable c) { if (c == null) return; try { c.close(); } catch (final Throwable t) { } }
From source file:Main.java
public static void close(Closeable cl) { try {//w ww .j av a 2 s. c o m if (cl != null) { cl.close(); } } catch (IOException ex) { throw new RuntimeException("Couldn't close resource", ex); } }
From source file:Main.java
public static void closeQuietly(Closeable paramCloseable) { if (paramCloseable != null) ;/*from w ww . j ava2s. c o m*/ try { paramCloseable.close(); return; } catch (IOException localIOException) { } }
From source file:Main.java
private static void safeCloseClosable(@Nullable Closeable closeable) { try {/*from w ww .ja v a2s . c o m*/ if (closeable != null) { closeable.close(); } } catch (IOException e) { e.printStackTrace(); } }
From source file:Main.java
/** * Closes the specified stream.//from w w w . j av a 2s . c o m * * @param stream The stream to close. */ private static void closeStream(Closeable stream) { if (stream != null) { try { stream.close(); } catch (IOException e) { // Ignore } } }
From source file:Main.java
/** * /*from w ww .j ava2s .c om*/ * The method try to close safely an object that implementes Closable * interface. If an error occurs, the method will NOT throw any exception, * but will * * return false * * * * @param closeable * * @return False if fail, otherwise return true. */ public static boolean close(java.io.Closeable closeable) { if (closeable != null) { try { closeable.close(); } catch (IOException ex) { return false; } } return true; }
From source file:Main.java
/** * If the argument is non-null, close the Closeable ignoring any {@link IOException}. *///from w ww . ja va 2 s . c o m public static void closeQuietly(Closeable closeable) { if (closeable != null) { try { closeable.close(); } catch (IOException e) { // Ignore. } } }
From source file:Main.java
public static void closeSilently(final Closeable closeable) { if (closeable != null) { try {/*from w w w .j a v a2s . c o m*/ closeable.close(); } catch (Exception exc) { // Do nothing } } }