public void close() throws IOException { if (mOut != null) { if (mOutPtr > 0) { mOut.write(mOutBuffer, 0, mOutPtr); mOutPtr = 0; } OutputStream out = mOut; mOut = null; byte[] buf = mOutBuffer; if (buf != null) { mOutBuffer = null; mContext.releaseWriteIOBuffer(buf); } out.close(); /* Let's 'flush' orphan surrogate, no matter what; but only * after cleanly closing everything else. */ int code = mSurrogate; mSurrogate = 0; if (code > 0) { throwIllegal(code); } } }