按点(.)切分,必须要注意转义!如:split("\\.")。
例子:
public class Test {
public static void main(String[] args) {
String s = "adhahd.txt";
String t[] = s.split("\\.");
for(int i = 0; i < t.length; i++){
System.out.println(t[i]);
}
}
}
输出结果:
adhahd
txt