| | |
| | | import java.security.MessageDigest; |
| | | import java.text.DecimalFormat; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * 文件帮助类 |
| | |
| | | |
| | | /** |
| | | * 获取文件名 |
| | | * |
| | | * @param file |
| | | * @return |
| | | */ |
| | | public static String getFileName(String file) { |
| | | int idx = file.lastIndexOf(File.separator); |
| | |
| | | } |
| | | |
| | | return ""; |
| | | } |
| | | |
| | | /** |
| | | * 获取文件名称 |
| | | */ |
| | | public static String getName(String file) { |
| | | String fileName = getFileName(file); |
| | | int idx = fileName.lastIndexOf("."); |
| | | if (idx > -1) { |
| | | return fileName.substring(0, idx); |
| | | } |
| | | |
| | | return fileName; |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | /** |
| | | * 获取多用途互联网邮件扩展类型 |
| | | * |
| | | * @param ext 文件扩展名 |
| | | * @return |
| | | */ |
| | | public static String getMime(String ext) { |
| | | switch (ext) { |
| | |
| | | /** |
| | | * 根据路径获取文件 |
| | | */ |
| | | public static void getFilesByPath(List<File> list, String path) { |
| | | public static void getFilesByPath(List<String> list, String path) { |
| | | File file = new File(path); |
| | | if (file.isDirectory()) { |
| | | File[] files = file.listFiles(); |
| | |
| | | if (f.isDirectory()) { |
| | | getFilesByPath(list, f.getPath()); |
| | | } else { |
| | | list.add(f); |
| | | list.add(f.getPath()); |
| | | } |
| | | } |
| | | } else { |
| | | list.add(file); |
| | | list.add(file.getPath()); |
| | | } |
| | | } |
| | | |