UnsyncPrintWriter extends PrintWriter { @Override public void println() { if (_writer == null) { _hasError = true; } else { try { _writer.write(_LINE_SEPARATOR); } catch (InterruptedIOException interruptedIOException) { Thread currentThread = Thread.currentThread(); currentThread.interrupt(); } 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 testPrintln() { StringWriter stringWriter = new StringWriter(); UnsyncPrintWriter unsyncPrintWriter = new UnsyncPrintWriter( stringWriter); unsyncPrintWriter.println(); String lineSeparator = System.getProperty("line.separator"); Assert.assertEquals(lineSeparator, stringWriter.toString()); StringBuffer stringBuffer = stringWriter.getBuffer(); stringBuffer.setLength(0); unsyncPrintWriter.println(true); Assert.assertEquals("true" + lineSeparator, stringWriter.toString()); stringBuffer.setLength(0); unsyncPrintWriter.println(false); Assert.assertEquals("false" + lineSeparator, stringWriter.toString()); stringBuffer.setLength(0); unsyncPrintWriter.println('c'); Assert.assertEquals("c" + lineSeparator, stringWriter.toString()); stringBuffer.setLength(0); unsyncPrintWriter.println(new char[] {'a', 'b', 'c'}); Assert.assertEquals("abc" + lineSeparator, stringWriter.toString()); stringBuffer.setLength(0); unsyncPrintWriter.println(3.14D); Assert.assertEquals("3.14" + lineSeparator, stringWriter.toString()); stringBuffer.setLength(0); unsyncPrintWriter.println(1.62F); Assert.assertEquals("1.62" + lineSeparator, stringWriter.toString()); stringBuffer.setLength(0); unsyncPrintWriter.println(10); Assert.assertEquals("10" + lineSeparator, stringWriter.toString()); stringBuffer.setLength(0); unsyncPrintWriter.println(100L); Assert.assertEquals("100" + lineSeparator, stringWriter.toString()); stringBuffer.setLength(0); unsyncPrintWriter.println( new Object() { @Override public String toString() { return "test"; } }); Assert.assertEquals("test" + lineSeparator, stringWriter.toString()); stringBuffer.setLength(0); unsyncPrintWriter.println((String)null); Assert.assertEquals("null" + lineSeparator, stringWriter.toString()); stringBuffer.setLength(0); unsyncPrintWriter.println("テスト"); Assert.assertEquals("テスト" + lineSeparator, stringWriter.toString()); unsyncPrintWriter.close(); unsyncPrintWriter.println(); Assert.assertTrue(unsyncPrintWriter.checkError()); }