//String[] aa = "aaa|bbb|ccc".split("|");//错误 String[] aa = "aaa|bbb|ccc".split("\\|"); //正确 for (int i = 0 ; i <aa.length ; i++ ) { System.out.println("--"+aa[i]); }
“.”和“|”都是转义字符,必须得加"\\";