java生成一个方法获取该字符串=docfilepicturejpeg中的picture
public static String getFileName(String path) { File file = new File(path); String fileName = file.getName(); int dotIndex = fileName.lastIndexOf("."); if (dotIndex > 0) { fileName = fileName.substring(0, dotIndex); } return fileName; }
调用方式: String path = "doc/file/picture.jpeg"; String fileName = getFileName(path); System.out.println(fileName); // 输出:picture
原文地址: https://www.cveoy.top/t/topic/f37V 著作权归作者所有。请勿转载和采集!