public void flushQuietly(Flushable s) { if (s != null) { try { s.flush(); } catch (IOException e) { e.printStackTrace(); } } }
protected boolean flush(Flushable flushable) { if (flushable != null) { try { flushable.flush(); return true; } catch (IOException e) { // mute } } return false; }
public static void close(final Closeable closeable) { if (closeable == null) return; try { if (Flushable.class.isInstance(closeable)) { ((Flushable) closeable).flush(); } } catch (Throwable e) { // Ignore } try { closeable.close(); } catch (Throwable e) { // Ignore } }
/** * Method that will close an {@link java.io.Closeable} ignoring it if it is null and ignoring * exceptions. * * @param closeable the closeable to close. * @since jEdit 4.3pre8 */ public static void closeQuietly(Closeable closeable) { if (closeable != null) { try { if (closeable instanceof Flushable) { ((Flushable) closeable).flush(); } } catch (IOException e) { // ignore } try { closeable.close(); } catch (IOException e) { // ignore } } } // }}}
/** * Method that will close a {@link Writer} ignoring it if it is null and ignoring exceptions. * * @param out the Writer to close. */ public static void closeQuietly(Writer out) { if (out != null) { try { if (out instanceof Flushable) { ((Flushable) out).flush(); } } catch (IOException e) { // ignore } try { out.close(); } catch (IOException e) { // ignore } } }
public static void flush(Object o) throws IOException { if (o instanceof Flushable) ((Flushable) o).flush(); }