/** Constructs a new empty buffer. */ public NonSyncDataOutputBuffer() { this(new NonSyncByteArrayOutputStream()); }
/** * Returns the current contents of the buffer. Data is only valid to * {@link #getLength()}. */ public byte[] getData() { return buffer.getData(); }
/** Returns the length of the valid data currently in the buffer. */ public int getLength() { return buffer.getLength(); }
/** Writes bytes from a DataInput directly into the buffer. */ public void write(DataInput in, int length) throws IOException { buffer.write(in, length); }
/** * {@inheritDoc} */ @Override public void write(int b) { enLargeBuffer(1); buf[count] = (byte) b; count += 1; }
/** Resets the buffer to empty. */ public NonSyncDataOutputBuffer reset() { written = 0; buffer.reset(); return this; }
/** Writes bytes from a DataInput directly into the buffer. */ public void write(DataInput in, int length) throws IOException { buffer.write(in, length); }
public void write(DataInput in, int length) throws IOException { enLargeBuffer(length); in.readFully(buf, count, length); count += length; }
/** Resets the buffer to empty. */ public NonSyncDataOutputBuffer reset() { written = 0; buffer.reset(); return this; }
@Override public void write(int b) throws IOException { buffer.write(b); incCount(1); }
/** * {@inheritDoc} */ @Override public void write(byte b[], int off, int len) { if ((off < 0) || (off > b.length) || (len < 0) || ((off + len) > b.length) || ((off + len) < 0)) { throw new IndexOutOfBoundsException(); } else if (len == 0) { return; } enLargeBuffer(len); System.arraycopy(b, off, buf, count, len); count += len; }
/** * Returns the current contents of the buffer. Data is only valid to * {@link #getLength()}. */ public byte[] getData() { return buffer.getData(); }
/** Resets the buffer to empty. */ public NonSyncDataOutputBuffer reset() { written = 0; buffer.reset(); return this; }
/** Returns the length of the valid data currently in the buffer. */ public int getLength() { return buffer.getLength(); }
/** Constructs a new empty buffer. */ public NonSyncDataOutputBuffer() { this(new NonSyncByteArrayOutputStream()); }
@Override public void write(byte b[], int off, int len) throws IOException { buffer.write(b, off, len); incCount(len); }
/** * {@inheritDoc} */ @Override public void write(int b) { enLargeBuffer(1); buf[count] = (byte) b; count += 1; }
/** * Returns the current contents of the buffer. Data is only valid to * {@link #getLength()}. */ public byte[] getData() { return buffer.getData(); }
/** Resets the buffer to empty. */ public NonSyncDataOutputBuffer reset() { written = 0; buffer.reset(); return this; }
/** Returns the length of the valid data currently in the buffer. */ public int getLength() { return buffer.getLength(); }