import java.nio.ByteBuffer; class test { public static void main(String[] args) { byte[] b1 = new byte[]{1,2}; byte[] b2 = new byte[]{3,4}; byte[] b = new byte[4]; ByteBuffer buf1 = ByteBuffer.allocate(2); ByteBuffer buf2 = ByteBuffer.allocate(2); buf1 = buf1.put(b1); b = buf1.array(); for(int i = 0; i != b.length; i++) System.out.println(b[i]); buf2 = buf2.put(b2); b = buf2.array(); for(int i = 0; i != b.length; i++) System.out.println(b[i]);
ByteBuffer buf3 = ByteBuffer.allocate(4); buf3.put(buf1.array()); buf3.put(buf2.array()); b = buf3.array(); for(int i = 0; i != b.length; i++) System.out.println(b[i]); } }
class test
{
public static void main(String[] args)
{
byte[] b1 = new byte[]{1,2};
byte[] b2 = new byte[]{3,4};
byte[] b = new byte[4];
ByteBuffer buf1 = ByteBuffer.allocate(2);
ByteBuffer buf2 = ByteBuffer.allocate(2);
buf1 = buf1.put(b1);
b = buf1.array();
for(int i = 0; i != b.length; i++)
System.out.println(b[i]);
buf2 = buf2.put(b2);
b = buf2.array();
for(int i = 0; i != b.length; i++)
System.out.println(b[i]);
ByteBuffer buf3 = ByteBuffer.allocate(4);
buf3.put(buf1.array());
buf3.put(buf2.array());
b = buf3.array();
for(int i = 0; i != b.length; i++)
System.out.println(b[i]);
}
}