private long inCoreLength() { final Block last = last(); return ((long) blocks.size() - 1) * Block.SZ + last.count; }
/** {@inheritDoc} */ @Override public void write(byte[] b, int off, int len) throws IOException { if (overflow == null) { while (len > 0) { Block s = last(); if (s.isFull()) { if (reachedInCoreLimit()) break; s = new Block(); blocks.add(s); } final int n = Math.min(s.buffer.length - s.count, len); System.arraycopy(b, off, s.buffer, s.count, n); s.count += n; len -= n; off += n; } } if (len > 0) overflow.write(b, off, len); }
/** {@inheritDoc} */ @Override public void write(int b) throws IOException { if (overflow != null) { overflow.write(b); return; } Block s = last(); if (s.isFull()) { if (reachedInCoreLimit()) { overflow.write(b); return; } s = new Block(); blocks.add(s); } s.buffer[s.count++] = (byte) b; }
/** * Copy all bytes remaining on the input stream into this buffer. * * @param in * the stream to read from, until EOF is reached. * @throws java.io.IOException * an error occurred reading from the input stream, or while * writing to a local temporary file. */ public void copy(InputStream in) throws IOException { if (blocks != null) { for (;;) { Block s = last(); if (s.isFull()) { if (reachedInCoreLimit()) break; s = new Block(); blocks.add(s); } int n = in.read(s.buffer, s.count, s.buffer.length - s.count); if (n < 1) return; s.count += n; } } final byte[] tmp = new byte[Block.SZ]; int n; while ((n = in.read(tmp)) > 0) overflow.write(tmp, 0, n); }
private long inCoreLength() { final Block last = last(); return ((long) blocks.size() - 1) * Block.SZ + last.count; }
private long inCoreLength() { final Block last = last(); return ((long) blocks.size() - 1) * Block.SZ + last.count; }
@Override public void write(final int b) throws IOException { if (overflow != null) { overflow.write(b); return; } Block s = last(); if (s.isFull()) { if (reachedInCoreLimit()) { overflow.write(b); return; } s = new Block(); blocks.add(s); } s.buffer[s.count++] = (byte) b; }
@Override public void write(final byte[] b, int off, int len) throws IOException { if (overflow == null) { while (len > 0) { Block s = last(); if (s.isFull()) { if (reachedInCoreLimit()) break; s = new Block(); blocks.add(s); } final int n = Math.min(s.buffer.length - s.count, len); System.arraycopy(b, off, s.buffer, s.count, n); s.count += n; len -= n; off += n; } } if (len > 0) overflow.write(b, off, len); }
/** {@inheritDoc} */ @Override public void write(int b) throws IOException { if (overflow != null) { overflow.write(b); return; } Block s = last(); if (s.isFull()) { if (reachedInCoreLimit()) { overflow.write(b); return; } s = new Block(); blocks.add(s); } s.buffer[s.count++] = (byte) b; }
/** {@inheritDoc} */ @Override public void write(byte[] b, int off, int len) throws IOException { if (overflow == null) { while (len > 0) { Block s = last(); if (s.isFull()) { if (reachedInCoreLimit()) break; s = new Block(); blocks.add(s); } final int n = Math.min(s.buffer.length - s.count, len); System.arraycopy(b, off, s.buffer, s.count, n); s.count += n; len -= n; off += n; } } if (len > 0) overflow.write(b, off, len); }
/** * Copy all bytes remaining on the input stream into this buffer. * * @param in * the stream to read from, until EOF is reached. * @throws java.io.IOException * an error occurred reading from the input stream, or while * writing to a local temporary file. */ public void copy(InputStream in) throws IOException { if (blocks != null) { for (;;) { Block s = last(); if (s.isFull()) { if (reachedInCoreLimit()) break; s = new Block(); blocks.add(s); } int n = in.read(s.buffer, s.count, s.buffer.length - s.count); if (n < 1) return; s.count += n; } } final byte[] tmp = new byte[Block.SZ]; int n; while ((n = in.read(tmp)) > 0) overflow.write(tmp, 0, n); }
/** * Copy all bytes remaining on the input stream into this buffer. * * @param in * the stream to read from, until EOF is reached. * @throws IOException * an error occurred reading from the input stream, or while * writing to a local temporary file. */ public void copy(final InputStream in) throws IOException { if (blocks != null) { for (;;) { Block s = last(); if (s.isFull()) { if (reachedInCoreLimit()) break; s = new Block(); blocks.add(s); } int n = in.read(s.buffer, s.count, s.buffer.length - s.count); if (n < 1) return; s.count += n; } } final byte[] tmp = new byte[Block.SZ]; int n; while ((n = in.read(tmp)) > 0) overflow.write(tmp, 0, n); }