### Question:
StringWriter extends StreamWriterBase<T> { @Override public StringWriter<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 StringWriter<T> duplicate();  }### Answer:
@Test public void testDuplicate() { StringWriter<String> writer = new StringWriter(StandardCharsets.UTF_16.name()); writer.setSyncOnFlush(true); StringWriter<String> other = writer.duplicate(); assertTrue(StreamWriterBaseComparator.equals(writer, other)); writer.setSyncOnFlush(false); assertFalse(StreamWriterBaseComparator.equals(writer, other)); assertFalse(StreamWriterBaseComparator.equals(writer, new StringWriter<>())); }