字符串切割(split())

public static void main(String[] args) throws Exception {     
    	String request = "0x23,0x55,0x55,0x55,0x55,0x0B,0x06,0x02,0x01,0x00,(byte) 0xD0,0x02,0x00,0x2A";
    	String strs[]=request.split(",|0x| |byte|\\(|\\)");
    	StringBuffer sb = new StringBuffer();
    	for(int i = 0;i<strs.length;i++){
    	    sb.append(strs[i]);        //append String並不擁有該方法,因此藉助StringBuffer
    	}
    	String sb1 = sb.toString();
    	System.out.println("sb1="+sb1);
      }
相關文章
相關標籤/搜索