@Override public synchronized void setLength(long newLength) throws IOException { // Flush before changing the file's length, otherwise the behavior of setLength() would be modified, especially // when truncating the file flush(); raos.setLength(newLength); }
public synchronized void seek(long offset) throws IOException { // Flush any buffered bytes before seeking, otherwise buffered bytes would be written at the wrong offset flush(); raos.seek(offset); }
/** * This method is overridden to release the internal buffer when this stream is closed. */ @Override public synchronized void close() throws IOException { if(buffer!=null) { // buffer is null if close() was already called try { flush(); } catch(IOException e) { // Continue anyway } // Release the buffer BufferPool.releaseByteArray(buffer); buffer = null; } raos.close(); }