List of usage examples for java.nio ByteBuffer allocate
public static ByteBuffer allocate(int capacity)
From source file:Main.java
public static byte[] getIntToByteArray(int num) { return ByteBuffer.allocate(4).putInt(num).array(); }
From source file:Main.java
public static byte[] longToByteArray(long number) { return ByteBuffer.allocate(8).putLong(number).array(); }
From source file:Main.java
public static final byte[] toByteArray(int value) { return ByteBuffer.allocate(4).putInt(value).array(); }
From source file:Main.java
public static byte[] longToBytes(long x) { ByteBuffer buffer = ByteBuffer.allocate(8); buffer.putLong(0, x);/*ww w .j a va 2s . com*/ return buffer.array(); }
From source file:Main.java
public static byte[] longToBytes(long x) { ByteBuffer buffer = ByteBuffer.allocate(Long.SIZE / 8); buffer.putLong(0, x);/*from www. ja v a 2s . co m*/ return buffer.array(); }
From source file:Main.java
public static byte[] convertintToBytes(final int i) { ByteBuffer bb = ByteBuffer.allocate(4); bb.putInt(i);/*from www .jav a2s . co m*/ return bb.array(); }
From source file:Main.java
public static byte[] getMessage(char move, long frame, int playerId) { return ByteBuffer.allocate(14).putChar(move).putLong(frame).putInt(playerId).array(); }
From source file:Main.java
public static byte[] intToBytes(int x) { ByteBuffer buffer = ByteBuffer.allocate(4); buffer.putInt(0, x);/*from ww w.j a va 2 s . c o m*/ byte[] array = buffer.array(); reverseArray(array); return array; }
From source file:Main.java
public static byte[] floatsToBytes(float[] floats) { ByteBuffer byteBuffer = ByteBuffer.allocate(floats.length * 4); byteBuffer.asFloatBuffer().put(floats); return byteBuffer.array(); }
From source file:Main.java
public static byte[] getCommandByteArray(int data) { byte[] ret;/*from ww w .j a v a 2 s. c om*/ ret = ByteBuffer.allocate(1).put(0, ((byte) data)).array(); return ret; }