Code example for ByteBuffer

Methods: array, clear, flip, position

0
        throw new UnsupportedOperationException();
    } 
 
    private void flushBytes() throws IOException { 
        int position;
        if ((position = mBytes.position()) > 0) {
            mBytes.flip();
            mOutputStream.write(mBytes.array(), 0, position);
            mBytes.clear();
        } 
    } 
 
    public void flush() throws IOException { 
        //Log.i("PackageManager", "flush mPos=" + mPos); 
        if (mPos > 0) {
            if (mOutputStream != null) {
                CharBuffer charBuffer = CharBuffer.wrap(mText, 0, mPos);
                CoderResult result = mCharset.encode(charBuffer, mBytes, true);
                while (true) { 
                    if (result.isError()) {
                        throw new IOException(result.toString());