- public static String getFileNameByFilePath(String path){
- String[] p = path.split(File.separator + File.separator);
- String fileName = p[p.length-1];
- return fileName;
- }
- /**
- * 根据文件的路径获取文件名
- * @param path
- * @return
- */
- public static String getFileName(String path){
- String fileName = new File(path).getName();
- return fileName;
- }
- //该片段来自于http://www.codesnippet.cn/detail/0112201411114.html
来源: http://www.codesnippet.cn/detail/0112201411114.html