最新消息: USBMI致力于为网友们分享Windows、安卓、IOS等主流手机系统相关的资讯以及评测、同时提供相关教程、应用、软件下载等服务。

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

IT圈 admin 1浏览 0评论

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);}}

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);}}

发布评论

评论列表 (0)

  1. 暂无评论