Anonymous
public java v1 · immutableByteBuffer b = ByteBuffer.allocateDirect(2048); //System.out.println("Sending:"); //SimpleProtocolDecoder.printHex(packet.getBytes()); b.put(packet.getBytes()); int size = b.position() + 2; byte[] pcktLength = {(byte)(size & 0xff), (byte)(size >> 8 &0xff)}; b = ByteBuffer.allocateDirect(size); b.put(pcktLength); b.put(packet.getBytes()); b.flip(); return b;