public static int convertIntFromBytes(byte[] byteArray) { return convertIntFromBytes(byteArray, 0); }
protected static byte[] deflate(byte[] bytes) { int size = bytes.length; if (size == 4) { int possibleMagic = ByteUtils.convertIntFromBytes(bytes); if (possibleMagic == NULL_OBJECT) return NULL_BYTES; else if (possibleMagic == DEFAULT_OBJECT) return DEFAULT_BYTES; } for (int x = 0; x < bytes.length; x++) { if (bytes[x] != 0) break; size--; } if (size == 0) return new byte[1]; byte[] rVal = new byte[1 + size]; rVal[0] = (byte) size; for (int x = 1; x < rVal.length; x++) rVal[x] = bytes[bytes.length - size - 1 + x]; return rVal; }
public static float convertFloatFromBytes(byte[] byteArray, int offset) { // Convert it to an int int number = convertIntFromBytes(byteArray, offset); return Float.intBitsToFloat(number); }
/** * Read in an integer from an InputStream * * @param inputStream * The InputStream used to read the integer * @return An int, which is the next 4 bytes converted from the InputStream * @throws IOException * Thrown if there is a problem reading from the InputStream */ public static int readInt(InputStream inputStream) throws IOException { byte[] byteArray = new byte[4]; // Read in the next 4 bytes inputStream.read(byteArray); int number = convertIntFromBytes(byteArray); return number; }
protected int readInt(byte[] content) throws IOException { byte[] bytes = inflateFrom(content, index); index += 1 + bytes.length; bytes = ByteUtils.rightAlignBytes(bytes, 4); int value = ByteUtils.convertIntFromBytes(bytes); if (value == BinaryOutputCapsule.NULL_OBJECT || value == BinaryOutputCapsule.DEFAULT_OBJECT) index -= 4; return value; }
int dataLength = ByteUtils.convertIntFromBytes(dataArray, loc); loc+=4;
public static int convertIntFromBytes(byte[] byteArray) { return convertIntFromBytes(byteArray, 0); }
public static int convertIntFromBytes(byte[] byteArray) { return convertIntFromBytes(byteArray, 0); }
protected static byte[] deflate(byte[] bytes) { int size = bytes.length; if (size == 4) { int possibleMagic = ByteUtils.convertIntFromBytes(bytes); if (possibleMagic == NULL_OBJECT) return NULL_BYTES; else if (possibleMagic == DEFAULT_OBJECT) return DEFAULT_BYTES; } for (int x = 0; x < bytes.length; x++) { if (bytes[x] != 0) break; size--; } if (size == 0) return new byte[1]; byte[] rVal = new byte[1 + size]; rVal[0] = (byte) size; for (int x = 1; x < rVal.length; x++) rVal[x] = bytes[bytes.length - size - 1 + x]; return rVal; }
protected static byte[] deflate(byte[] bytes) { int size = bytes.length; if (size == 4) { int possibleMagic = ByteUtils.convertIntFromBytes(bytes); if (possibleMagic == NULL_OBJECT) return NULL_BYTES; else if (possibleMagic == DEFAULT_OBJECT) return DEFAULT_BYTES; } for (int x = 0; x < bytes.length; x++) { if (bytes[x] != 0) break; size--; } if (size == 0) return new byte[1]; byte[] rVal = new byte[1 + size]; rVal[0] = (byte) size; for (int x = 1; x < rVal.length; x++) rVal[x] = bytes[bytes.length - size - 1 + x]; return rVal; }
public static float convertFloatFromBytes(byte[] byteArray, int offset) { // Convert it to an int int number = convertIntFromBytes(byteArray, offset); return Float.intBitsToFloat(number); }
public static float convertFloatFromBytes(byte[] byteArray, int offset) { // Convert it to an int int number = convertIntFromBytes(byteArray, offset); return Float.intBitsToFloat(number); }
/** * Read in an integer from an InputStream * * @param inputStream * The InputStream used to read the integer * @return An int, which is the next 4 bytes converted from the InputStream * @throws IOException * Thrown if there is a problem reading from the InputStream */ public static int readInt(InputStream inputStream) throws IOException { byte[] byteArray = new byte[4]; // Read in the next 4 bytes inputStream.read(byteArray); int number = convertIntFromBytes(byteArray); return number; }
/** * Read in an integer from an InputStream * * @param inputStream * The InputStream used to read the integer * @return An int, which is the next 4 bytes converted from the InputStream * @throws IOException * Thrown if there is a problem reading from the InputStream */ public static int readInt(InputStream inputStream) throws IOException { byte[] byteArray = new byte[4]; // Read in the next 4 bytes inputStream.read(byteArray); int number = convertIntFromBytes(byteArray); return number; }
protected int readInt(byte[] content) throws IOException { byte[] bytes = inflateFrom(content, index); index += 1 + bytes.length; bytes = ByteUtils.rightAlignBytes(bytes, 4); int value = ByteUtils.convertIntFromBytes(bytes); if (value == BinaryOutputCapsule.NULL_OBJECT || value == BinaryOutputCapsule.DEFAULT_OBJECT) index -= 4; return value; }
protected int readInt(byte[] content) throws IOException { byte[] bytes = inflateFrom(content, index); index += 1 + bytes.length; bytes = ByteUtils.rightAlignBytes(bytes, 4); int value = ByteUtils.convertIntFromBytes(bytes); if (value == BinaryOutputCapsule.NULL_OBJECT || value == BinaryOutputCapsule.DEFAULT_OBJECT) index -= 4; return value; }
int dataLength = ByteUtils.convertIntFromBytes(dataArray, loc); loc+=4;
int dataLength = ByteUtils.convertIntFromBytes(dataArray, loc); loc+=4;