Commit 75e2c147 by guanguan1009

Merge branch 'master' of http://gitlab.dev.jtyjy.com/guanguan1009/pdf2pptx

# Conflicts:
#	src/main/java/com/jtyjy/pdf2pptx/converter/Pdf2Pptx.java
#	src/main/java/com/jtyjy/pdf2pptx/support/Constant.java
parents 8650aefb 8aaa4473
package com.jtyjy.pdf2pptx.application;
import com.jtyjy.pdf2pptx.service.ConverterService;
import com.jtyjy.pdf2pptx.support.Constant;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.util.Calendar;
import java.util.Date;
@Component
public class AppListener implements ApplicationListener<ContextRefreshedEvent> {
@Value("${file.path}")
private String filepath;
private final static Logger logger = LoggerFactory.getLogger(AppListener.class);
@Autowired
private ConverterService converterService;
@Override
public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) {
System.err.println("正在处理 " + filepath);
System.err.println("处理开始 " + new Date());
converterService.converterPdf2Pptx(filepath);
System.err.println("处理完成 " + new Date());
}
}
......@@ -199,6 +199,53 @@ public class FileUtil {
return dirNameList;
}
//删除指定文件夹下所有文件
public static boolean delAllFile(String path) {
boolean flag = false;
File file = new File(path);
if (!file.exists()) {
return flag;
}
if (!file.isDirectory()) {
return flag;
}
String[] tempList = file.list();
File temp = null;
for (int i = 0; i < tempList.length; i++) {
if (path.endsWith(File.separator)) {
temp = new File(path + tempList[i]);
} else {
temp = new File(path + File.separator + tempList[i]);
}
if (temp.isFile()) {
temp.delete();
}
if (temp.isDirectory()) {
delAllFile(path + "/" + tempList[i]);//先删除文件夹里面的文件
delFolder(path + "/" + tempList[i]);//再删除空文件夹
flag = true;
}
}
return flag;
}
//删除文件夹
//param folderPath 文件夹完整绝对路径
public static boolean delFolder(String folderPath) {
try {
delAllFile(folderPath); //删除完里面所有内容
String filePath = folderPath;
filePath = filePath.toString();
java.io.File myFilePath = new java.io.File(filePath);
return myFilePath.delete(); //删除空文件夹
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
public static void main(String[] args) {
List<String> allDirPathName = getAllDirPathName("F:\\pdf图片");
for (String s : allDirPathName) {
......
# 注意斜杠
file:
path: D:\\document
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment