类 FileUtil
java.lang.Object
cn.warpin.core.util.FileUtil
-
字段概要
字段 -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明private static BufferedImagebase64String2BufferedImage(String base64string) static BufferedImagebase64ToBufferedImage(String base64String) private static InputStreamBaseToInputStream(String base64string) static BooleancheckFileExist(String filePath, String fileName) static org.springframework.http.MediaTypecontentTypeSelector(String extension) static voidcreateFile(String path, byte[] content) static StringcreateFile(String filePath, String fileName) static voidcreateFolder(String path) 创建文件夹static voiddeleteFile(String fileName) static voiddeleteFile(String path, String fileName) static booleandeleteFolder(File folder) static voiddeleteFullPathFile(String fileFullPath) static voidgenerateImage(String base64, String targetPath, String extensionName) private static StringgetFileExtension(String fileName) 获取文件扩展名static StringgetFileExtension(Path filePath) static StringgetFileType(String fileName) static StringgetHtmlFromUrl(String url) 从url获取Html内容static intgetIntFromColor(int Red, int Green, int Blue) 通过RGB只获取int值static intgetIntFromColor(int Red, int Green, int Blue, int Alpha) static org.springframework.web.multipart.MultipartFilegetMultipartFile(String path) 通过路径获取MultipartFilestatic StringgetOssKey(String filename, String ossContext, String project, String type, String context, String content, String platform, boolean isWindows) 获取保存文件的key,包含路径private static StringimageToBase64(BufferedImage bufferedImage) static FilemultipartFileToFile(org.springframework.web.multipart.MultipartFile multipartFile, String fileName) 保存文件到本地queryFileOfFolder(String path, String suffix) 查看文件夹下的所有文件static StringremoveFileExtension(Path filePath) static Stringstatic String重命名文件,生成一个唯一的文件名static StringsaveBufferedImageToFile(String base64string, String extensionName) static voidstatic voidstatic String保存文件,文件名已经重命名
-
字段详细资料
-
RESOURCE_PATH
-
-
构造器详细资料
-
FileUtil
public FileUtil()
-
-
方法详细资料
-
createFile
-
checkFileExist
-
getFileType
-
rename
-
resetName
重命名文件,生成一个唯一的文件名- 参数:
fileName- 原始文件名- 返回:
- 唯一的新文件名(UUID + 扩展名)
-
getFileExtension
获取文件扩展名- 参数:
fileName- 文件名- 返回:
- 文件扩展名(如 ".pdf")
-
getFileExtension
-
removeFileExtension
-
contentTypeSelector
-
multipartFileToFile
public static File multipartFileToFile(org.springframework.web.multipart.MultipartFile multipartFile, String fileName) throws Exception 保存文件到本地- 参数:
multipartFile-- 抛出:
IOExceptionException
-
createFolder
创建文件夹- 参数:
path-- 抛出:
Exception
-
saveFile
- 参数:
file- 前端上传的文件path- 存到本地的路径 含文件名- 抛出:
Exception
-
saveFile
public static String saveFile(org.springframework.web.multipart.MultipartFile file, String path, String fmtName) 保存文件,文件名已经重命名- 参数:
file-path-fmtName-- 返回:
-
deleteFile
-
deleteFile
-
deleteFullPathFile
-
deleteFolder
-
saveFile
- 抛出:
Exception
-
createFile
- 抛出:
IOException
-
getMultipartFile
通过路径获取MultipartFile- 参数:
path-- 返回:
- 抛出:
IOException
-
queryFileOfFolder
查看文件夹下的所有文件- 参数:
path-- 返回:
- 抛出:
IOException
-
saveBufferedImageToFile
public static String saveBufferedImageToFile(String base64string, String extensionName) throws Exception - 抛出:
Exception
-
base64ToBufferedImage
-
base64String2BufferedImage
- 抛出:
Exception
-
BaseToInputStream
- 抛出:
Exception
-
imageToBase64
- 抛出:
Exception
-
generateImage
- 参数:
base64- base64编码字符串targetPath- 图片路径-具体到文件extensionName- 后缀
-
getHtmlFromUrl
从url获取Html内容- 返回:
-
getIntFromColor
public static int getIntFromColor(int Red, int Green, int Blue) 通过RGB只获取int值- 参数:
Red-Green-Blue-- 返回:
-
getIntFromColor
public static int getIntFromColor(int Red, int Green, int Blue, int Alpha) -
getOssKey
public static String getOssKey(String filename, String ossContext, String project, String type, String context, String content, String platform, boolean isWindows) 获取保存文件的key,包含路径- 参数:
filename-ossContext-project-type-context-content-isWindows-- 返回:
-