数据封装(dataFormat)
简介
将多段数据封装成byte数组快速传输
添加数据
public Chli addData(byte b);
public Chli addData(byte[] b);
public Chli addData(int index,byte[] b);
public Chli addDatas(Collection<byte[]> c);
public Chli reLoadData(List<byte[]> data);
编码数据
public byte[] encodeV1();
解编码
public Chli decode(byte[] encodeData);
使用示例
String a="123";
byte b=2;
byte[] c= {1,2,3,4};
byte[] enc=new Chli().addData(a.getBytes("utf-8")).addData(b).addData(c).encodeV1();
Chli chli=new Chli().decode(enc);
List<byte[]> l= chli.getDatas();
System.out.println(new String(l.get(0),"utf-8"));//"123"
System.out.println(l.get(1)[0]);//2
System.out.println(Hex.encodeHex(l.get(2)));//1,2,3,4