public class Test10 { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub String test = "D:\\MyEclipse8.6.1\\workspace\\PagingWeb1\\WebRoot\\img\\j4.jpg"; String[] result = test.split("\\\\"); System.out.println(result[result.length-1]); }}请注意Java中对特殊字符的转义处理
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String test = "D:\\MyEclipse8.6.1\\workspace\\PagingWeb1\\WebRoot\\img\\j4.jpg";
String[] result = test.split("\\\\");
System.out.println(result[result.length-1]);
}}请注意Java中对特殊字符的转义处理