package com.wml.am;
public class test {
public test() {
super();
}
public static void main(String[] args) {
String test = "461.jpg";
int t = test.indexOf(".");
System.out.println(test.substring(t+1, test.length()));
String path = "C:\\Users\\wenmingliang\\Desktop\\461.jpg";
int a = path.lastIndexOf("\\");
int d = path.indexOf("\\");
System.out.println(path.substring(0, d));
System.out.println(a);
System.out.println(path.substring(a+1, path.length()));
String str = "12,45,56,89";//你给的字符串
int b = str.lastIndexOf(",");
int c = str.indexOf(",");
System.out.println(c);
System.out.println(str.substring(0, c));
System.out.println((path.substring(a+1, path.length())).getClass());
System.out.println(str.substring(b+1, str.length()));
String[] strArray = str.split(",");//使用split方法根据逗号将字符串拆分成字符串数组
System.out.println(strArray[strArray.length-1]);
for (int i = 0; i < strArray.length; i++) {
System.out.print(strArray[i] + " ");
}
}
}
截取字符串
最新推荐文章于 2019-04-19 11:25:10 发布