|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object de.vdheide.utils.Bytes
Takes an array of bytes (e.g. read from an InputStream) and converts it into a number, assuming MSB order.
Constructor Summary | |
Bytes(byte[] in)
Create a new object from an array of bytes and convert to number. |
|
Bytes(byte[] in,
int start,
int length)
Create a new object from an array of bytes and convert to a number. |
|
Bytes(long in)
Create a new object from a long value und convert to array of bytes. |
|
Bytes(long in,
int len)
Create a new object from a long value und convert to array of bytes. |
Method Summary | |
static long |
byteArrayToLong(byte[] in,
int start,
int length)
Convert length bytes from an array of bytes starting at
position start to a long value. |
byte[] |
getBytes()
|
long |
getValue()
|
static byte[] |
longToByteArray(long in,
int len)
Convert long value to array of bytes. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Bytes(byte[] in)
getValue()
.
in
- Array to convert.public Bytes(byte[] in, int start, int length)
getValue()
.
in
- Array to convert.start
- First index in in
to readlength
- Number of bytes to readpublic Bytes(long in)
getBytes()
.
in
- Value to convertpublic Bytes(long in, int len)
getBytes()
.
in
- Value to convertlen
- Length of resulting byte arrayMethod Detail |
public long getValue()
public byte[] getBytes()
public static long byteArrayToLong(byte[] in, int start, int length)
length
bytes from an array of bytes starting at
position start
to a long value.
in
- Array of bytes to convertstart
- First index in in
to readlength
- Number of bytes to read
public static byte[] longToByteArray(long in, int len)
in
- Long value to convertlen
- Length of resulting byte array. -1
for minimum
length needed.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |