From 8e79771fd46206cdb6fb698f5dc78dc41886238f Mon Sep 17 00:00:00 2001 From: cmg <527198563@qq.com> Date: 星期一, 27 五月 2024 14:29:23 +0800 Subject: [PATCH] Merge branch 'matesr-prod-new' into master-stander --- src/main/java/com/hx/util/FileConvertTool.java | 24 ++++++++++++++++++++---- 1 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/hx/util/FileConvertTool.java b/src/main/java/com/hx/util/FileConvertTool.java index 1598f98..da21ef8 100644 --- a/src/main/java/com/hx/util/FileConvertTool.java +++ b/src/main/java/com/hx/util/FileConvertTool.java @@ -44,8 +44,7 @@ /** * 鑾峰彇鏂囦欢base64瀛楃涓� * @param urlPath 鏂囦欢璺緞 - * @return - * @throws IOException + * @return 杩斿洖base64缂栫爜 */ public static String getFileBaseStrByUrl(String urlPath) throws IOException { InputStream is = getUrlFile(urlPath); @@ -110,10 +109,10 @@ File file = null; try { File dir = new File(filePath); - if(!dir.exists()&&dir.isDirectory()){//鍒ゆ柇鏂囦欢鐩綍鏄惁瀛樺湪 + if(!dir.exists()){//鍒ゆ柇鏂囦欢鐩綍鏄惁瀛樺湪 dir.mkdirs(); } - file = new File(filePath+"\\"+fileName); + file = new File(filePath+"/"+fileName); fos = new FileOutputStream(file); bos = new BufferedOutputStream(fos); bos.write(bfile); @@ -264,6 +263,23 @@ } /** + * 鍒犻櫎鍗曚釜鏂囦欢 + * @param file 琚垹闄ゆ枃浠� + * @return 鍗曚釜鏂囦欢鍒犻櫎鎴愬姛杩斿洖true锛屽惁鍒欒繑鍥瀎alse + */ + public static boolean deleteFile(File file) { + if(file == null){ + return true; + } + // 璺緞涓烘枃浠朵笖涓嶄负绌哄垯杩涜鍒犻櫎 + if (file.isFile() && file.exists()) { + file.delete(); + return true; + } + return false; + } + + /** * 鍒犻櫎鐩綍锛堟枃浠跺す锛変互鍙婄洰褰曚笅鐨勬枃浠� * @param sPath 琚垹闄ょ洰褰曠殑鏂囦欢璺緞 * @return 鐩綍鍒犻櫎鎴愬姛杩斿洖true锛屽惁鍒欒繑鍥瀎alse -- Gitblit v1.8.0