xujunwei před 6 měsíci
rodič
revize
3985054910

+ 25 - 0
framework-common/src/main/java/com/mrxu/framework/common/util/FileFunc.java

@@ -302,5 +302,30 @@ public class FileFunc {
 		}
 	}
 
+	/**
+	 * 确保路径存在
+	 * @param path
+	 */
+	@SneakyThrows
+	public static void surePathExists(String path) {
+		// 目标文件夹路径
+		Path dirPath = Paths.get(path);
+		// 检查目录是否存在,如果不存在则创建
+		if (!Files.exists(dirPath)) {
+			Files.createDirectories(dirPath);
+		}
+	}
+
+	/**
+	 * 删除文件
+	 * @param path
+	 */
+	public static void deleteFile(String path) {
+		File file = new File(path);
+		if(file.exists()) {
+			file.delete();
+		}
+	}
+
 
 }