if (out == null) throw new NullPointerException("Null writer");
if (out instanceof OutputStreamWriter) {
this.encoding = ((OutputStreamWriter)out).getEncoding();
}
CharsetFactory factory = CharsetFactory.newInstance();
try {
this.charset = factory.getCharset(this.encoding);
} catch (UnsupportedEncodingException e) {
this.charset = factory.getCharset();
}
this.encoding = this.charset.getName();
this.out = new BufferedWriter(out);
}