替换字符串中的特殊字符

来源:互联网 发布:dota2数据查看 编辑:程序博客网 时间:2024/05/16 18:47

public static int getLength(String str){
     str =     str.replaceAll("[^x00-xff]*", "");
     System.out.println("替换后的字符串为:"+str);
     return str.length();
 }

public static void main(String[] args) {
  // TODO Auto-generated method stub  
     String str = "http://192.168.1.1:8080/resources\\电话.xls";
     System.out.println("cccc:"+getLength(str));

        
 }