FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
JavaExercises/Experiments/ReadZipFile.java at master · biblelamp/JavaExercises · GitHub
biblelamp
/
JavaExercises
Public
Notifications
You must be signed in to change notification settings
Fork
130
Star
153
Code
Issues
1
Pull requests
9
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
JavaExercises
/
Experiments
/
ReadZipFile.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
35 lines (32 loc) · 1.06 KB
Breadcrumbs
JavaExercises
/
Experiments
/
ReadZipFile.java
Copy path
File metadata and controls
35 lines (32 loc) · 1.06 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/**
* Reading Zip files
* get from: https://metanit.com/java/tutorial/6.12.php
* see also:
* http://java-code.ru/java-dlya-nachinayushhix/zip-arxivy-v-yazyke-java/
*/
import
java
.
io
.*;
import
java
.
util
.*;
import
java
.
util
.
zip
.*;
class
ReadZipFile
{
public
static
void
main
(
String
[]
args
) {
try
(
ZipInputStream
zin
=
new
ZipInputStream
(
new
FileInputStream
(
"example.zip"
))) {
ZipEntry
entry
;
String
name
;
long
size
;
while
((
entry
=
zin
.
getNextEntry
()) !=
null
) {
name
=
entry
.
getName
();
// get file name
size
=
entry
.
getSize
();
// get file size in bytes
System
.
out
.
printf
(
"Name: %s
\t
size: %d
\n
"
,
name
,
size
);
if
(
name
.
endsWith
(
".java"
)) {
Scanner
in
=
new
Scanner
(
zin
);
while
(
in
.
hasNextLine
())
System
.
out
.
println
(
in
.
nextLine
());
}
}
}
catch
(
Exception
ex
){
System
.
out
.
println
(
ex
.
getMessage
());
}
}
}
Back
|
FazBrowse Home
|
New Git URL