File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change
1
+ Manifest-Version : 1.0
2
+ Main-Class : isc.zlib.Java
3
+
Original file line number Diff line number Diff line change
1
+ package isc .zlib ;
2
+
3
+ import java .util .Arrays ;
4
+ import java .util .zip .Deflater ;
5
+
6
+ public abstract class Java {
7
+
8
+ public static byte [] compress (String inputString ) {
9
+ byte [] output = new byte [100 ];
10
+ try {
11
+ // Encode a String into bytes
12
+ byte [] input = inputString .getBytes ("UTF-8" );
13
+
14
+ // Compress the bytes
15
+
16
+ Deflater compresser = new Deflater ();
17
+ compresser .setInput (input );
18
+ compresser .finish ();
19
+ int compressedDataLength = compresser .deflate (output );
20
+ compresser .end ();
21
+ output = Arrays .copyOfRange (output , 0 , compressedDataLength );
22
+
23
+ } catch (java .io .UnsupportedEncodingException ex ) {
24
+ // handle
25
+ }
26
+
27
+
28
+ return output ;
29
+ }
30
+ }
You can’t perform that action at this time.
0 commit comments