StringWriter extends StreamWriterBase<T> { @Override public Writer<T> duplicate() { return new StringWriter<>(this); } StringWriter();  StringWriter(String charsetName); protected  StringWriter(StringWriter<T> other); @Override void open(FileSystem fs, Path path); @Override void write(T element); @Override Writer<T> duplicate(); @Override int hashCode(); @Override boolean equals(Object other);  }
@Test public void testDuplicate() { StringWriter<String> writer = new StringWriter(StandardCharsets.UTF_16.name()); writer.setSyncOnFlush(true); Writer<String> other = writer.duplicate(); assertTrue(writer.equals(other)); writer.setSyncOnFlush(false); assertFalse(writer.equals(other)); assertFalse(writer.equals(new StringWriter<>())); }