FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
zstack/utils/src/main/java/org/zstack/utils/Compresser.java at master · zstackio/zstack · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
zstackio
/
zstack
Public
Notifications
You must be signed in to change notification settings
Fork
399
Star
1.4k
Code
Issues
163
Pull requests
13
Actions
Projects
Wiki
Security and quality
4
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
zstack
/
utils
/
src
/
main
/
java
/
org
/
zstack
/
utils
/
Compresser.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
46 lines (41 loc) · 1.54 KB
Breadcrumbs
zstack
/
utils
/
src
/
main
/
java
/
org
/
zstack
/
utils
/
Compresser.java
Copy path
File metadata and controls
executable file
·
46 lines (41 loc) · 1.54 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
36
37
38
39
40
41
42
43
44
45
46
package
org
.
zstack
.
utils
;
import
java
.
io
.
ByteArrayInputStream
;
import
java
.
io
.
ByteArrayOutputStream
;
import
java
.
io
.
IOException
;
import
java
.
util
.
zip
.
Deflater
;
import
java
.
util
.
zip
.
DeflaterOutputStream
;
import
java
.
util
.
zip
.
Inflater
;
import
java
.
util
.
zip
.
InflaterInputStream
;
public
class
Compresser
{
public
static
byte
[]
deflate
(
byte
[]
input
)
throws
IOException
{
return
deflate
(
input
,
8192
);
}
public
static
byte
[]
deflate
(
byte
[]
input
,
int
bufferSize
)
throws
IOException
{
ByteArrayOutputStream
out
=
new
ByteArrayOutputStream
(
input
.
length
);
Deflater
def
=
new
Deflater
();
DeflaterOutputStream
dos
=
new
DeflaterOutputStream
(
out
,
def
,
bufferSize
);
dos
.
write
(
input
,
0
,
input
.
length
);
dos
.
finish
();
dos
.
close
();
byte
[]
ret
=
out
.
toByteArray
();
out
.
close
();
return
ret
;
}
public
static
byte
[]
inflate
(
byte
[]
input
,
int
bufferSize
)
throws
IOException
{
ByteArrayInputStream
in
=
new
ByteArrayInputStream
(
input
);
Inflater
inf
=
new
Inflater
();
InflaterInputStream
iis
=
new
InflaterInputStream
(
in
,
inf
,
bufferSize
);
ByteArrayOutputStream
out
=
new
ByteArrayOutputStream
(
input
.
length
*
5
);
for
(
int
c
=
iis
.
read
();
c
!= -
1
;
c
=
iis
.
read
()) {
out
.
write
(
c
);
}
in
.
close
();
iis
.
close
();
byte
[]
ret
=
out
.
toByteArray
();
out
.
close
();
return
ret
;
}
public
static
byte
[]
inflate
(
byte
[]
input
)
throws
IOException
{
return
inflate
(
input
,
8192
);
}
}
Back
|
FazBrowse Home
|
New Git URL