String filePath = "group1/M00/00/02/wKgBil9QhcOAZkm5AAJ-5AaXPtQ147.jpg";
// 截取点前的字符串
String path = filePath.substring(0, filePath.indexOf("."));
// 截取点后的字符串
String suffix = filePath.substring(path.length() + 1);
// 拼接成缩略图地址
String file = path + "_500x500." + suffix;
// record/test/123456(生成地址的时候,输入的那个参数)/2022-05-06-10-25-01_2022-05-06-10-27-44.mp4
String objectName = "record/test/123456/2022-05-06-10-25-01_2022-05-06-10-27-44.mp4";
System.out.println(objectName.substring(objectName.lastIndexOf("/") + 1)); // 2022-05-06-10-25-01_2022-05-06-10-27-44.mp4
String str = objectName.substring(objectName.lastIndexOf("/",objectName.lastIndexOf("/") -1)+ 1);
String sourceId = str.substring(0,str.indexOf("/"));
System.out.println("直播id:" + sourceId);
String path = "record/test/123456/2022-05-06-10-25-01_2022-05-06-10-27-44.mp4";
// 截取倒数第二个"/"之前的字符串
String s = path.substring(0, path.lastIndexOf("/", path.lastIndexOf("/") - 1));
//"-1"代表在定位时往前取一位,即去掉"/";从path.lastIndexOf("/")-1位置开始向前寻找倒数第二个"/"的位置;最后用substring()方法来进行截取
System.out.println(s);
// 截取倒数第二个"/"之后的字符串
String path1 = "record/test/123456/2022-05-06-10-25-01_2022-05-06-10-27-44.mp4";
String s1 = path1.substring(path1.lastIndexOf("/", path1.lastIndexOf("/") - 1) + 1);
//"+1"代表在定位时往后取一位,即去掉"/";"-1"代表以"/"字符定位的位置向前取一位;从path1.lastIndexOf("/")-1位置开始向前寻找倒数第二个"/"的位置
System.out.println(s1);