jme.utility
Class Conversion
java.lang.Object
jme.utility.Conversion
- public class Conversion
- extends java.lang.Object
Conversion
provides static methods for unit conversion.
Special thanks to Chman's site for help.
- Author:
- Mark Powell
Method Summary |
static float |
byte2float(byte[] bytes,
int index)
byte2float converts four bytes to a float by
first converting the bytes into and int and then converting
that into a float using Float.intBitsToFloat . |
static int |
byte2int(byte[] bytes,
int index)
byte2int converts four bytes to an int. |
static short |
byte2short(byte[] bytes,
int index)
byte2short converts two bytes to a short. |
static java.lang.String |
byte2String(byte[] b)
byte2String converts an array of bytes into
a string. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Conversion
public Conversion()
byte2short
public static final short byte2short(byte[] bytes,
int index)
byte2short
converts two bytes to a short. The
bytes are contained in an array with the starting index provided.
Two bytes are read (index and index+1).
- Parameters:
bytes
- the bytes to convert.index
- the pointer to the start of the bytes.
- Returns:
- the short value defined by the two bytes.
byte2int
public static final int byte2int(byte[] bytes,
int index)
byte2int
converts four bytes to an int. The
bytes are contained in an array with the starting index
provided. Four bytes are read (index, index+1, index+2, and
index+3).
- Parameters:
bytes
- the bytes to convert.index
- the pointer to the start of the bytes.
- Returns:
- the int value defined by the four bytes.
byte2float
public static final float byte2float(byte[] bytes,
int index)
byte2float
converts four bytes to a float by
first converting the bytes into and int and then converting
that into a float using Float.intBitsToFloat
.
- Parameters:
bytes
- the bytes to convert.index
- the pointer to the start of the bytes.
- Returns:
- the int value defined by the four bytes.
byte2String
public static final java.lang.String byte2String(byte[] b)
byte2String
converts an array of bytes into
a string. The bytes are read until a trailing zero is
encountered. Leading zeros are ignored.
- Parameters:
b
- the bytes to convert to a String.
- Returns:
- the String value of the given bytes.