UnsyncPrintWriter extends PrintWriter { @Override public void close() { try { if (_writer == null) { return; } _writer.close(); _writer = null; } catch (IOException ioException) { _hasError = true; } } UnsyncPrintWriter(File file);  UnsyncPrintWriter(File file, String csn);  UnsyncPrintWriter(OutputStream outputStream);  UnsyncPrintWriter(String fileName);  UnsyncPrintWriter(String fileName, String csn);  UnsyncPrintWriter(Writer writer); @Override PrintWriter append(char c); @Override PrintWriter append(CharSequence charSequence); @Override PrintWriter append(CharSequence charSequence, int start, int end); @Override boolean checkError(); @Override void close(); @Override void flush(); @Override PrintWriter format(
		Locale locale, String format, Object... arguments); @Override PrintWriter format(String format, Object... arguments); @Override void print(boolean b); @Override void print(char c); @Override void print(char[] chars); @Override void print(double d); @Override void print(float f); @Override void print(int i); @Override void print(long l); @Override void print(Object object); @Override void print(String string); @Override PrintWriter printf(
		Locale locale, String format, Object... arguments); @Override PrintWriter printf(String format, Object... arguments); @Override void println(); @Override void println(boolean b); @Override void println(char c); @Override void println(char[] chars); @Override void println(double d); @Override void println(float f); @Override void println(int i); @Override void println(long l); @Override void println(Object object); @Override void println(String string); void reset(Writer writer); @Override void write(char[] chars); @Override void write(char[] chars, int offset, int length); @Override void write(int c); @Override void write(String string); @Override void write(String string, int offset, int length);  }
@Test public void testClose() { AtomicBoolean calledClose = new AtomicBoolean(); UnsyncPrintWriter unsyncPrintWriter = new UnsyncPrintWriter( new StringWriter() { @Override public void close() { calledClose.set(true); } }); unsyncPrintWriter.close(); Assert.assertTrue(calledClose.get()); calledClose.set(false); unsyncPrintWriter.close(); Assert.assertFalse(calledClose.get()); unsyncPrintWriter.reset( new StringWriter() { @Override public void close() throws IOException { throw new IOException(); } }); unsyncPrintWriter.close(); Assert.assertTrue(unsyncPrintWriter.checkError()); }