|
|
|
@ -42,6 +42,7 @@ public class HtmlToPdfConverter {
|
|
|
|
|
Path dirPath = Paths.get(path, "temporary", split[0], split[1], split[2]);
|
|
|
|
|
try {
|
|
|
|
|
Files.createDirectories(dirPath);
|
|
|
|
|
clearTemporaryDirectory(Paths.get(path, "temporary")); // 清理目录
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
throw new RuntimeException("创建文件夹失败: " + e.getMessage(), e);
|
|
|
|
|
}
|
|
|
|
@ -206,6 +207,15 @@ public class HtmlToPdfConverter {
|
|
|
|
|
return null; // 处理异常或返回特定的错误值
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void clearTemporaryDirectory(Path directory) {
|
|
|
|
|
File dir = directory.toFile();
|
|
|
|
|
if (dir.exists() && dir.isDirectory()) {
|
|
|
|
|
for (File file : dir.listFiles()) {
|
|
|
|
|
if (!file.isDirectory()) {
|
|
|
|
|
file.delete(); // 删除文件
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|