###### qq_36604562

2018-10-29 07:25 阅读 402

# 来来来 老哥们帮我解析下 很急

40

##0187ST=32;CN=2011;PW=123456;MN=399HOLL0000219;CP=&&DataTime=20171219000 933;B01TOTAL-Rtd=3.75;011-Rtd=23.6,011-Flag=N;060-Rtd=0.16,060-Flag=N;001-Rtd=7.06,001-F lag=N;B01-Rtd=3.755,B01-Flag=N&&FE41

``````            解析成ST=32,CN=2011,PW=123456,MN=399HOLL0000219,DataTime=20171219000933,B01TOTAL-Rtd=3.75,011-Rtd=23.6,011-Flag=N,060-Rtd=0.16,060-Flag=N,001-Rtd=7.06,001-F lag=N,B01-Rtd=3.755,B01-Flag=N
``````
• 点赞
• 写回答
• 关注问题
• 收藏
• 复制链接分享

#### 2条回答默认 最新

• 已采纳
Run_the_ant 2018-10-29 07:35
``````public static void main (String[] args) {
String data = "##0187ST=32;CN=2011;PW=123456;MN=399HOLL0000219;CP=&&DataTime=20171219000933;B01TOTAL-Rtd=3.75;011-Rtd=23.6,011-Flag=N;060-Rtd=0.16,060-Flag=N;001-Rtd=7.06,001-Flag=N;B01-Rtd=3.755,B01-Flag=N&&FE41";
String result = data.substring(6,data.length()).replaceAll(";", ",").replace("CP=&&", "");
result = result.substring(0, result.indexOf("&&"));

String[] resultList = result.split(",");
System.out.println(resultList.toString());
}
``````

输出结果：
resultList={ST=32,CN=2011,PW=123456,MN=399HOLL0000219,DataTime=20171219000933,B01TOTAL-Rtd=3.75,011-Rtd=23.6,011-Flag=N,060-Rtd=0.16,060-Flag=N,001-Rtd=7.06,001-Flag=N,B01-Rtd=3.755,B01-Flag=N}

点赞 1 评论 复制链接分享
• K beasts 2018-10-29 07:33

采纳，代码右键 - 审查元素。

点赞 1 评论 复制链接分享