|
|
|
|
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.torweg.pulse.util.io.ByteUtils
public final class ByteUtils
provides methods to convert Java primitive types to a byte array representation and vice versa.
Internally it uses DataInputStream and DataOutputStream to do
the conversions.
| Nested Class Summary | |
|---|---|
static class |
ByteUtils.ByteFormatException
indicates an exception converting a byte array back to a primitive type. |
| Method Summary | |
|---|---|
static byte[] |
getBytes(double d)
returns the double as four bytes (internally converting the double to a long using Double.doubleToLongBits(double)), high byte first. |
static byte[] |
getBytes(float f)
returns the float as four bytes (internally converting the float to an int using Float.floatToIntBits(float)), high byte first. |
static byte[] |
getBytes(int i)
returns the int as four bytes, high byte first. |
static byte[] |
getBytes(long l)
returns the long as eight bytes, high byte first. |
static double |
getDouble(byte[] b)
returns the first eight bytes of the given byte array as a double, (internally converting the double to a long using Double.longBitsToDouble(long)), high byte
first. |
static float |
getFloat(byte[] b)
returns the first four bytes of the given byte array as an float , (internally converting the float to an int using Float.intBitsToFloat(int)), high byte first. |
static int |
getInt(byte[] b)
returns the first four bytes of the given byte array as an int (high byte first). |
static long |
getLong(byte[] b)
returns the first four bytes of the given byte array as an int (high byte first). |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static byte[] getBytes(int i)
i - the int
public static int getInt(byte[] b)
b - the byte array
public static byte[] getBytes(long l)
l - the long
public static long getLong(byte[] b)
b - the byte array
public static byte[] getBytes(float f)
Float.floatToIntBits(float)), high byte first.
f - the float
public static float getFloat(byte[] b)
Float.intBitsToFloat(int)), high byte first.
b - the byte array
public static byte[] getBytes(double d)
Double.doubleToLongBits(double)), high byte first.
d - the double
public static double getDouble(byte[] b)
Double.longBitsToDouble(long)), high byte
first.
b - the byte array
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||