ByteArraypublic class ByteArray extends Object A simple wrapper around a byte array, with a start position and
count of bytes. |
Fields Summary |
---|
private byte[] | bytes | private int | start | private int | count |
Constructors Summary |
---|
public ByteArray(byte[] b, int start, int count)Constructor
bytes = b;
this.start = start;
this.count = count;
| public ByteArray(int size)Constructor that creates a byte array of the specified size.
this(new byte[size], 0, size);
|
Methods Summary |
---|
public byte[] | getBytes()Returns the internal byte array. Note that this is a live
reference to the actual data, not a copy.
return bytes;
| public int | getCount()Returns the count of bytes
return count;
| public byte[] | getNewBytes()Returns a new byte array that is a copy of the data.
byte[] b = new byte[count];
System.arraycopy(bytes, start, b, 0, count);
return b;
| public int | getStart()Returns the start position
return start;
| public void | grow(int incr)Grow the byte array by incr bytes.
byte[] nbuf = new byte[bytes.length + incr];
System.arraycopy(bytes, 0, nbuf, 0, bytes.length);
bytes = nbuf;
| public void | setCount(int count)Set the count of bytes.
this.count = count;
| public java.io.ByteArrayInputStream | toByteArrayInputStream()Returns a ByteArrayInputStream.
return new ByteArrayInputStream(bytes, start, count);
|
|