| | |
| | | package com.lf.server.helper; |
| | | |
| | | import java.io.File; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 文件帮助类 |
| | |
| | | |
| | | /** |
| | | * 获取文件扩展名 |
| | | * |
| | | * @param file 文件 |
| | | * @return |
| | | */ |
| | | public static String getExtension(File file) { |
| | | if (file == null) { |
| | |
| | | return fileName.substring(idx); |
| | | } |
| | | |
| | | /** |
| | | * 获取文件扩展名 |
| | | */ |
| | | public static String getExtension(String fileName) { |
| | | if (StringHelper.isEmpty(fileName)) { |
| | | return ""; |
| | | } |
| | | |
| | | int idx = fileName.lastIndexOf(POINT); |
| | | if (idx == -1) { |
| | | return ""; |
| | | } |
| | | |
| | | return fileName.substring(idx).toLowerCase(); |
| | | } |
| | | |
| | | /** |
| | | * 获取多用途互联网邮件扩展类型 |
| | |
| | | return "application/octet-stream"; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取临时路径 |
| | | * |
| | | * @return |
| | | */ |
| | | public static String getTempPath() { |
| | | return StringHelper.YMD_HM_FORMAT.format(new Date()); |
| | | } |
| | | } |