/** Writes a single byte. * @see IndexInput#readByte() */ public void writeByte(byte b) throws IOException { if (bufferPosition >= BUFFER_SIZE) flush(); buffer[bufferPosition++] = b; }
/** Expert: implements buffer write. Writes bytes at the current position in * the output. * @param b the bytes to write * @param len the number of bytes to write */ private void flushBuffer(byte[] b, int len) throws IOException { flushBuffer(b, 0, len); }
/** Random-access methods */ public void seek(long pos) throws IOException { super.seek(pos); file.seek(pos); } public long length() throws IOException {
flush(); } else { flush(); flushBuffer(b, offset, length); bufferStart += length; } else { flush(); bytesLeft = bufferSize;
public void close() throws IOException { // only close the file if it has not been closed yet if (isOpen) { boolean success = false; try { super.close(); success = true; } finally { isOpen = false; if (!success) { try { file.close(); } catch (Throwable t) { // Suppress so we don't mask original exception } } else file.close(); } } }
/** Random-access methods */ public void seek(long pos) throws IOException { super.seek(pos); file.seek(pos); } public long length() throws IOException {
flush(); } else { flush(); flushBuffer(b, offset, length); bufferStart += length; } else { flush(); bytesLeft = BUFFER_SIZE;
public void close() throws IOException { // only close the file if it has not been closed yet if (isOpen) { boolean success = false; try { super.close(); success = true; } finally { isOpen = false; if (!success) { try { file.close(); } catch (Throwable t) { // Suppress so we don't mask original exception } } else file.close(); } } }
/** Random-access methods */ public void seek(long pos) throws IOException { super.seek(pos); file.seek(pos); } public long length() throws IOException {
flush(); } else { flush(); flushBuffer(b, offset, length); bufferStart += length; } else { flush(); bytesLeft = BUFFER_SIZE;
public void close() throws IOException { // only close the file if it has not been closed yet if (isOpen) { boolean success = false; try { super.close(); success = true; } finally { isOpen = false; if (!success) { try { file.close(); } catch (Throwable t) { // Suppress so we don't mask original exception } } else file.close(); } } }
@Override public void seek(long pos) throws IOException { flush(); bufferStart = pos; }
/** Forces any buffered output to be written. */ public void flush() throws IOException { flushBuffer(buffer, bufferPosition); bufferStart += bufferPosition; bufferPosition = 0; }
/** Random-access methods */ @Override public void seek(long pos) throws IOException { super.seek(pos); file.seek(pos); }
public void close() throws IOException { // only close the file if it has not been closed yet if (isOpen) { boolean success = false; try { super.close(); success = true; } finally { isOpen = false; if (!success) { try { file.close(); } catch (Throwable t) { // Suppress so we don't mask original exception } } else file.close(); } } }
/** Writes a single byte. * @see IndexInput#readByte() */ public void writeByte(byte b) throws IOException { if (bufferPosition >= BUFFER_SIZE) flush(); buffer[bufferPosition++] = b; }
/** Expert: implements buffer write. Writes bytes at the current position in * the output. * @param b the bytes to write * @param len the number of bytes to write */ private void flushBuffer(byte[] b, int len) throws IOException { flushBuffer(b, 0, len); }
/** Random-access methods */ public void seek(long pos) throws IOException { super.seek(pos); file.seek(pos); } public long length() throws IOException {
@Override public void close() throws IOException { try { super.close(); } finally { delegate.close(); } }
/** Sets current position in this file, where the next write will occur. * @see #getFilePointer() */ public void seek(long pos) throws IOException { flush(); bufferStart = pos; }