GZip.java
1.73 KB
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
47
48
49
50
51
52
/*
* Decompiled with CFR 0_118.
*/
package com.adobe.livecycle.formsservice.sharedutils;
import com.adobe.livecycle.formsservice.logging.FormsLogger;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
public class GZip {
public static byte[] ungzip(byte[] input) throws IOException {
long startTime = FormsLogger.logPerformance(false, 0, "<GZip-ungzip>");
ByteArrayInputStream is = new ByteArrayInputStream(input);
ByteArrayOutputStream os = new ByteArrayOutputStream();
GZIPInputStream gis = new GZIPInputStream(is);
byte[] chrs = new byte[512];
try {
int nRead;
while ((nRead = gis.read(chrs, 0, 512)) != -1) {
os.write(chrs, 0, nRead);
}
}
catch (EOFException oEOF) {
// empty catch block
}
gis.close();
is.close();
byte[] outputbytes = os.toByteArray();
os.close();
FormsLogger.logPerformance(true, startTime, "</GZip-ungzip>");
return outputbytes;
}
public static byte[] gzip(byte[] input) throws IOException {
long startTime = FormsLogger.logPerformance(false, 0, "<GZip-gzip>");
ByteArrayOutputStream os = new ByteArrayOutputStream();
GZIPOutputStream gos = new GZIPOutputStream(os);
gos.write(input, 0, input.length);
gos.close();
byte[] outputbytes = os.toByteArray();
os.close();
FormsLogger.logPerformance(true, startTime, "</GZip-gzip>");
return outputbytes;
}
}