public static void main(String[] args) {
/*
TLV 解析
*/
String tag = "30";
String code = "32 01 00 AE 90 02 00 01 02 30 03 00 AB 32 31 31 02 00 32 33 33 01 00 CC";
String[] codes = code.split(" ");
StringBuilder result = new StringBuilder();
for (int i = 0; i < codes.length; i++) {
if (tag.equals(codes[i]) && codes[i+1].startsWith("0")) {
int len = Integer.parseInt(codes[i+1]);
for (int j = 0; j < len; j++) {
result.append(codes[i+3+j]).append(" ");
}
}
}
System.out.println(result);
}
TLV解析#算法#字符串
最新推荐文章于 2024-10-19 10:59:36 发布