@Test public void testIntToBytes() { int b = 123; byte[] bb = BytesUtils.intToBytes(b); int bf = BytesUtils.bytesToInt(bb); assertEquals("testBytesToFloat", b, bf); }
public static byte[] intToBytes(int i) { return new byte[]{(byte) ((i >> 24) & 0xFF), (byte) ((i >> 16) & 0xFF), (byte) ((i >> 8) & 0xFF), (byte) (i & 0xFF)}; }
BytesUtils { public static byte[] intToBytes(int i) { return new byte[]{(byte) ((i >> 24) & 0xFF), (byte) ((i >> 16) & 0xFF), (byte) ((i >> 8) & 0xFF), (byte) (i & 0xFF)}; } }
BytesUtils { public static byte[] intToBytes(int i) { return new byte[]{(byte) ((i >> 24) & 0xFF), (byte) ((i >> 16) & 0xFF), (byte) ((i >> 8) & 0xFF), (byte) (i & 0xFF)}; }  }
BytesUtils { public static byte[] intToBytes(int i) { return new byte[]{(byte) ((i >> 24) & 0xFF), (byte) ((i >> 16) & 0xFF), (byte) ((i >> 8) & 0xFF), (byte) (i & 0xFF)}; }  static byte[] intToBytes(int i); static byte[] intToBytes(int i, byte[] desc, int offset); static void intToBytes(int srcNum, byte[] result, int pos, int width); static byte[] intToTwoBytes(int i); static int twoBytesToInt(byte[] ret); static int bytesToInt(byte[] bytes); static int bytesToInt(byte[] bytes, int offset); static int bytesToInt(byte[] result, int pos, int width); static byte[] floatToBytes(float x); static void floatToBytes(float x, byte[] desc, int offset); static float bytesToFloat(byte[] b); static float bytesToFloat(byte[] b, int offset); static byte[] doubleToBytes(double data); static void doubleToBytes(double d, byte[] bytes, int offset); static double bytesToDouble(byte[] bytes); static double bytesToDouble(byte[] bytes, int offset); static byte[] boolToBytes(boolean x); static byte[] boolToBytes(boolean x, byte[] desc, int offset); static boolean bytesToBool(byte[] b); static boolean bytesToBool(byte[] b, int offset); static byte[] longToBytes(long num); static byte[] longToBytes(long num, int len); static byte[] longToBytes(long num, byte[] desc, int offset); static void longToBytes(long srcNum, byte[] result, int pos, int width); static long bytesToLong(byte[] byteNum); static long bytesToLong(byte[] byteNum, int len); static long bytesToLong(byte[] result, int pos, int width); static long bytesToLongFromOffset(byte[] byteNum, int len, int offset); static byte[] stringToBytes(String str); static String bytesToString(byte[] byteStr); static byte[] concatByteArray(byte[] a, byte[] b); static byte[] concatByteArrayList(List<byte[]> list); static byte[] subBytes(byte[] src, int start, int length); static int getIntN(int data, int offset); static int setIntN(int data, int offset, int value); static int getByteN(byte data, int offset); static byte setByteN(byte data, int offset, int value); static int getLongN(long data, int offset); static long setLongN(long data, int offset, int value); static double readDouble(InputStream in); static float readFloat(InputStream in); static boolean readBool(InputStream in); static int readInt(InputStream in); static long readLong(InputStream in); static byte[] safeReadInputStreamToBytes(int count, InputStream in); static byte[] shortToBytes(short number); static short bytesToShort(byte[] b); }
BytesUtils { public static byte[] intToBytes(int i) { return new byte[]{(byte) ((i >> 24) & 0xFF), (byte) ((i >> 16) & 0xFF), (byte) ((i >> 8) & 0xFF), (byte) (i & 0xFF)}; }  static byte[] intToBytes(int i); static byte[] intToBytes(int i, byte[] desc, int offset); static void intToBytes(int srcNum, byte[] result, int pos, int width); static byte[] intToTwoBytes(int i); static int twoBytesToInt(byte[] ret); static int bytesToInt(byte[] bytes); static int bytesToInt(byte[] bytes, int offset); static int bytesToInt(byte[] result, int pos, int width); static byte[] floatToBytes(float x); static void floatToBytes(float x, byte[] desc, int offset); static float bytesToFloat(byte[] b); static float bytesToFloat(byte[] b, int offset); static byte[] doubleToBytes(double data); static void doubleToBytes(double d, byte[] bytes, int offset); static double bytesToDouble(byte[] bytes); static double bytesToDouble(byte[] bytes, int offset); static byte[] boolToBytes(boolean x); static byte[] boolToBytes(boolean x, byte[] desc, int offset); static boolean bytesToBool(byte[] b); static boolean bytesToBool(byte[] b, int offset); static byte[] longToBytes(long num); static byte[] longToBytes(long num, int len); static byte[] longToBytes(long num, byte[] desc, int offset); static void longToBytes(long srcNum, byte[] result, int pos, int width); static long bytesToLong(byte[] byteNum); static long bytesToLong(byte[] byteNum, int len); static long bytesToLong(byte[] result, int pos, int width); static long bytesToLongFromOffset(byte[] byteNum, int len, int offset); static byte[] stringToBytes(String str); static String bytesToString(byte[] byteStr); static byte[] concatByteArray(byte[] a, byte[] b); static byte[] concatByteArrayList(List<byte[]> list); static byte[] subBytes(byte[] src, int start, int length); static int getIntN(int data, int offset); static int setIntN(int data, int offset, int value); static int getByteN(byte data, int offset); static byte setByteN(byte data, int offset, int value); static int getLongN(long data, int offset); static long setLongN(long data, int offset, int value); static double readDouble(InputStream in); static float readFloat(InputStream in); static boolean readBool(InputStream in); static int readInt(InputStream in); static long readLong(InputStream in); static byte[] safeReadInputStreamToBytes(int count, InputStream in); static byte[] shortToBytes(short number); static short bytesToShort(byte[] b);  }