|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.rit.util.ByteSequence
public class ByteSequence
Class ByteSequence provides an abstraction for a sequence of bytes. The contents of the byte sequence are specified at construction time; the contents may come from a byte array, an input stream, or another byte sequence. You can obtain the byte sequence's contents as a byte array or write the byte sequence's contents to an output stream.
| Constructor Summary | |
|---|---|
ByteSequence(byte[] buf)
Construct a new byte sequence whose contents are a copy of the given byte array. |
|
ByteSequence(byte[] buf,
int off,
int len)
Construct a new byte sequence whose contents are a copy of a portion of the given byte array. |
|
ByteSequence(ByteSequence theByteSequence)
Construct a new byte sequence whose contents are a copy of the given byte sequence. |
|
ByteSequence(InputStream theInputStream)
Construct a new byte sequence whose contents come from the given input stream. |
|
| Method Summary | |
|---|---|
int |
copy(byte[] buf)
Copy this byte sequence's contents into the given byte array. |
int |
copy(byte[] buf,
int off,
int len)
Copy this byte sequence's contents into a portion of the given byte array. |
int |
length()
Obtain the length of this byte sequence. |
byte[] |
toByteArray()
Obtain a byte array with a copy of this byte sequence's contents. |
void |
write(DataOutput theOutputStream)
Write this byte sequence's contents to the given data output stream. |
void |
write(OutputStream theOutputStream)
Write this byte sequence's contents to the given output stream. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ByteSequence(byte[] buf)
buf - Byte array to copy.
NullPointerException - Thrown if buf is null.
public ByteSequence(byte[] buf,
int off,
int len)
buf - Byte array to copy.off - Index of first byte to copy.len - Number of bytes to copy.
NullPointerException - Thrown if buf is null.
IndexOutOfBoundsException - Thrown if off < 0, len < 0, or
off+len > buf.length.
public ByteSequence(InputStream theInputStream)
throws IOException
theInputStream - Input stream, or null.
IOException - Thrown if an I/O error occurred.public ByteSequence(ByteSequence theByteSequence)
theByteSequence - Byte sequence to copy.
NullPointerException - Thrown if theByteSequence is null.| Method Detail |
|---|
public int length()
public byte[] toByteArray()
public int copy(byte[] buf)
buf - Buffer to hold the copy.
NullPointerException - (unchecked exception) Thrown if buf is null.
public int copy(byte[] buf,
int off,
int len)
buf - Buffer to hold the copy.off - Index in buf at which to start copying.len - Maximum number of bytes to copy.
NullPointerException - (unchecked exception) Thrown if buf is null.
IndexOutOfBoundsException - Thrown if off < 0, len < 0, or
off+len > buf.length.
public void write(OutputStream theOutputStream)
throws IOException
theOutputStream - Output stream.
IOException - Thrown if an I/O error occurred.
public void write(DataOutput theOutputStream)
throws IOException
theOutputStream - Data output stream.
IOException - Thrown if an I/O error occurred.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||