如何获取视频文件的扩展名 1.视频文件 String file =“海王.mp4” 2.获取视频文件的扩展名 //lastIndexOf:获取最后字符“.”的下标 int index =file.lastIndexOf(“.”); 3.截取字符串,只保留扩展名 String str=file.substring(index+1);