Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pdf2pptx
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guanzixin
pdf2pptx
Commits
8aaa4473
Commit
8aaa4473
authored
Jul 11, 2019
by
guanguan1009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改
parent
c1cde5f9
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
48 deletions
+49
-48
src/main/java/com/jtyjy/pdf2pptx/converter/Pdf2Pptx.java
+2
-48
src/main/java/com/jtyjy/pdf2pptx/support/FileUtil.java
+47
-0
No files found.
src/main/java/com/jtyjy/pdf2pptx/converter/Pdf2Pptx.java
View file @
8aaa4473
...
@@ -27,7 +27,7 @@ public class Pdf2Pptx {
...
@@ -27,7 +27,7 @@ public class Pdf2Pptx {
List
<
String
>
allDirPathName
=
new
ArrayList
<>();
List
<
String
>
allDirPathName
=
new
ArrayList
<>();
FileUtil
.
getAllDirPathNameRe
(
Constant
.
SOURCE_PATH
,
allDirPathName
);
FileUtil
.
getAllDirPathNameRe
(
Constant
.
SOURCE_PATH
,
allDirPathName
);
for
(
String
delFolder
:
allDirPathName
)
{
for
(
String
delFolder
:
allDirPathName
)
{
if
(
delFolder
(
delFolder
))
{
if
(
FileUtil
.
delFolder
(
delFolder
))
{
logger
.
info
(
"删除文件夹:{}及其文件成功"
,
delFolder
);
logger
.
info
(
"删除文件夹:{}及其文件成功"
,
delFolder
);
}
}
}
}
...
@@ -90,57 +90,11 @@ public class Pdf2Pptx {
...
@@ -90,57 +90,11 @@ public class Pdf2Pptx {
}
}
//删除所有生成的图片文件
//删除所有生成的图片文件
for
(
String
dirPathName
:
allDirPathName
)
{
for
(
String
dirPathName
:
allDirPathName
)
{
if
(
delFolder
(
dirPathName
))
{
if
(
d
irPathName
.
endsWith
(
"_图片"
)
&&
FileUtil
.
d
elFolder
(
dirPathName
))
{
logger
.
info
(
"删除文件夹:{}及其文件成功"
,
dirPathName
);
logger
.
info
(
"删除文件夹:{}及其文件成功"
,
dirPathName
);
}
}
}
}
}
}
//删除指定文件夹下所有文件
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
;
}
}
}
src/main/java/com/jtyjy/pdf2pptx/support/FileUtil.java
View file @
8aaa4473
...
@@ -199,6 +199,53 @@ public class FileUtil {
...
@@ -199,6 +199,53 @@ public class FileUtil {
return
dirNameList
;
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
)
{
public
static
void
main
(
String
[]
args
)
{
List
<
String
>
allDirPathName
=
getAllDirPathName
(
"F:\\pdf图片"
);
List
<
String
>
allDirPathName
=
getAllDirPathName
(
"F:\\pdf图片"
);
for
(
String
s
:
allDirPathName
)
{
for
(
String
s
:
allDirPathName
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment