public void setOutput(OutputStream os, String encoding) throws IOException,
            IllegalArgumentException, IllegalStateException {
        if (os == null)
            throw new IllegalArgumentException();
        if (true) {
            try {
                mCharset = Charset.forName(encoding).newEncoder()
                        .onMalformedInput(CodingErrorAction.REPLACE)
                        .onUnmappableCharacter(CodingErrorAction.REPLACE);
            } catch (IllegalCharsetNameException e) {
                throw (UnsupportedEncodingException) (new UnsupportedEncodingException(
                        encoding).initCause(e));
            } catch (UnsupportedCharsetException e) {
                throw (UnsupportedEncodingException) (new UnsupportedEncodingException(
                        encoding).initCause(e));
            }
            mOutputStream = os;
        } else {
            setOutput(
                    encoding == null
                            ? new OutputStreamWriter(os)
                            : new OutputStreamWriter(os, encoding));
        }
    }
Allocate a FastXmlSerializer with the given internal output buffer size.  If the
size is zero or negative, then the default buffer size will be used.

@param bufferSize Size in bytes of the in-memory output buffer that the writer will use.
android/android_framework/base/src/main/java/github/tornaco/android/thanos/core/util/FastXmlSerializer.java