Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
C
common
Project
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
曲欣亮
common
Commits
fd4d8fc9
Commit
fd4d8fc9
authored
Jan 19, 2021
by
张永
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
a6d0d26b
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
3 deletions
+38
-3
ZipUtil.java
src/main/java/com/egolm/common/ZipUtil.java
+38
-3
No files found.
src/main/java/com/egolm/common/ZipUtil.java
View file @
fd4d8fc9
...
...
@@ -137,11 +137,46 @@ public final class ZipUtil {
}
}
public
static
void
unzip1
(
File
file
,
String
descDir
)
{
ZipFile
zipFile
=
null
;
ZipInputStream
zis
=
null
;
try
{
zipFile
=
new
ZipFile
(
file
);
zis
=
new
ZipInputStream
(
new
FileInputStream
(
file
));
ZipEntry
entry
=
null
;
zis
.
getNextEntry
();
// 删了就没法解压
while
((
entry
=
zis
.
getNextEntry
())
!=
null
&&
!
entry
.
isDirectory
())
{
InputStream
is
=
zipFile
.
getInputStream
(
entry
);
String
fileName
=
descDir
+
File
.
separator
+
entry
.
getName
();
File
new_file
=
new
File
(
fileName
);
//存在则删除
if
(
new_file
.
exists
())
{
new_file
.
delete
();
}
FileUtil
.
streamToFile
(
is
,
fileName
);
}
}
catch
(
Exception
e
)
{
throw
new
ZipUtilException
(
e
);
}
finally
{
try
{
if
(
zipFile
!=
null
)
{
zipFile
.
close
();
}
if
(
zis
!=
null
)
{
zis
.
close
();
}
}
catch
(
Exception
e
)
{
throw
new
ZipUtilException
(
e
);
}
}
}
public
static
void
main
(
String
[]
args
)
{
String
targetPath
=
"D:\\data\\erp\\91310114594794273Y
"
;
/*String targetPath = "D:\\data\\erp\\91330110MA2B16CL0G
";
File file = ZipUtil.zip(targetPath);
System
.
out
.
println
(
file
.
getName
());
//ZipUtil.unzip(file, "D:\\data\\erp\\91310114594794273Y");
System.out.println(file.getName()); */
File
file
=
new
File
(
"C:\\Users\\zhangyong\\Desktop\\excel\\[7777]2021-01-14.zip"
);
ZipUtil
.
unzip
(
file
,
"C:\\Users\\zhangyong\\Desktop\\excel\\"
);
}
}
\ No newline at end of file
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