admin 管理员组

文章数量: 887021

xx:xx,xx:xx规则的字符串怎么解析呢

package com.gaofengTest;import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;public class GaoFengTest {public static void main(String[] args) {String code = "耳机喇叭";String t = null;List list = new ArrayList();String s = "显示屏:正常,外放喇叭:正常,听筒喇叭:正常,麦克:正常,耳机喇叭:未检测,耳机麦克:未检测,后置摄像头:正常,前置摄像头:正常,触摸屏:异常,按键:异常,传感器:异常,振动器:正常,";StringTokenizer fx = new StringTokenizer(s,",");int number = fx.countTokens();  while(fx.hasMoreTokens()){  String str = fx.nextToken();  System.out.println("当前单词:"+str); list.add(str);System.out.println("还剩"+fx.countTokens()+"个单词");  } System.out.println("List="+list.toString());for (int i = 0; i < list.size(); i++) {System.out.println(list.get(i));t = list.get(i).toString();System.out.println("j"+t.indexOf(code));
//            if( != -1){
//                System.out.println("最终截取结果:"+t);
//                return;
//            }if(t.contains(code)){System.out.println("最终截取结果:"+t);return;}}
//            ip = ip.substring(ip.lastIndexOf('/');
//            String t = "显示屏:正常";
//            t = t.substring(t.lastIndexOf(':')+1);
//            System.out.println("t="+t);}}

本文标签: xxxx xxxx规则的字符串怎么解析呢