public void write(byte b) throws IOException { if (pos >= buf.length) { written += pos; flush(buf, 0, buf.length); pos=0; } buf[pos++] = b; }
/** Only flushes the buffer of the FastOutputStream, not that of the * underlying stream. */ public void flushBuffer() throws IOException { if (pos > 0) { written += pos; flush(buf, 0, pos); pos=0; } }
public void write(byte b) throws IOException { if (pos >= buf.length) { written += pos; flush(buf, 0, buf.length); pos=0; } buf[pos++] = b; }
/** Only flushes the buffer of the FastOutputStream, not that of the * underlying stream. */ public void flushBuffer() throws IOException { if (pos > 0) { written += pos; flush(buf, 0, pos); pos=0; } }
@Override public void write(byte arr[], int off, int len) throws IOException { for(;;) { int space = buf.length - pos; if (len <= space) { System.arraycopy(arr, off, buf, pos, len); pos += len; return; } else if (len > buf.length) { if (pos>0) { flush(buf,0,pos); // flush written += pos; pos=0; } // don't buffer, just write to sink flush(arr, off, len); written += len; return; } // buffer is too big to fit in the free space, but // not big enough to warrant writing on its own. // write whatever we can fit, then flush and iterate. System.arraycopy(arr, off, buf, pos, space); written += buf.length; // important to do this first, since buf.length can change after a flush! flush(buf, 0, buf.length); pos = 0; off += space; len -= space; } }
@Override public void write(byte arr[], int off, int len) throws IOException { for(;;) { int space = buf.length - pos; if (len <= space) { System.arraycopy(arr, off, buf, pos, len); pos += len; return; } else if (len > buf.length) { if (pos>0) { flush(buf,0,pos); // flush written += pos; pos=0; } // don't buffer, just write to sink flush(arr, off, len); written += len; return; } // buffer is too big to fit in the free space, but // not big enough to warrant writing on its own. // write whatever we can fit, then flush and iterate. System.arraycopy(arr, off, buf, pos, space); written += buf.length; // important to do this first, since buf.length can change after a flush! flush(buf, 0, buf.length); pos = 0; off += space; len -= space; } }
/** * Used to write a marker for EOF */ private void writeNothing() throws IOException { fos.writeInt(0); fos.flush(); } }
fos.flush(); if (indexVersion != null && (packetsWritten % 5 == 0)) {