import java.nio.ByteBuffer;
class test
{
public static void main(String[] args)
{
byte[] b1 = new byte[]{1,2};
byte[] b2 = new byte[]{3,4};
ByteBuffer buf1 = ByteBuffer.allocate(2);
ByteBuffer buf2 = ByteBuffer.allocate(2);
buf1 = buf1.put(b1);
buf2 = buf2.put(b2);
ByteBuffer buf3 = ByteBuffer.allocate(4);
buf3.put(buf1.array());
buf3.put(buf2.array());
byte[] 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};
ByteBuffer buf1 = ByteBuffer.allocate(2);
ByteBuffer buf2 = ByteBuffer.allocate(2);
buf1 = buf1.put(b1);
buf2 = buf2.put(b2);
ByteBuffer buf3 = ByteBuffer.allocate(4);
buf3.put(buf1.array());
buf3.put(buf2.array());
byte[] b = buf3.array();
for(int i = 0; i != b.length; i++)
System.out.println(b[i]);
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货