protected void finalize() throws IOException { if (mLocalBuffer != null) { long count = mLocalBuffer.getBaseByteCount(); mLocalBuffer = null; mGroup.adjustLevel(-count); } }
private void spillover() throws IOException { mSpillover = mGroup.createFileByteBuffer(); // TODO: This is bad! By writing out the contents of the existing // buffer early, surrogates are evaluated too soon! mLocalBuffer.writeTo(new ByteBufferOutputStream(mSpillover)); long count = mLocalBuffer.getBaseByteCount(); mLocalBuffer = null; mGroup.adjustLevel(-count); }
public void append(byte[] bytes, int offset, int length) throws IOException { List captureBuffers; if ((captureBuffers = mCaptureBuffers) != null) { int size = captureBuffers.size(); for (int i = 0; i < size; i++) { ((ByteBuffer) captureBuffers.get(i)).append(bytes, offset, length); } } if (mSpillover == null) { if (mGroup.adjustLevel(length)) { mLocalBuffer.append(bytes, offset, length); return; } spillover(); } mSpillover.append(bytes, offset, length); }