fork download
  1. import java.util.*;
  2. import java.util.zip.*;
  3. import java.lang.*;
  4.  
  5. class Main
  6. {
  7. public static void test1 () throws Exception {
  8. byte[] output = new byte[20];
  9. Deflater compresser = new Deflater();
  10. compresser.setLevel(Deflater.BEST_COMPRESSION);
  11. compresser.setInput("blah".getBytes("UTF-8"));
  12. compresser.finish();
  13. int len = compresser.deflate(output);
  14. System.out.println("len="+ len+ " " +Arrays.toString(output));
  15. }
  16. public static void test2 () throws Exception {
  17. byte[] output = new byte[20];
  18. Deflater compresser = new Deflater(Deflater.BEST_COMPRESSION);
  19. compresser.setLevel(Deflater.BEST_COMPRESSION);
  20. compresser.setInput("blah".getBytes("UTF-8"));
  21. compresser.finish();
  22. int len = compresser.deflate(output);
  23. System.out.println("len="+ len+ " " +Arrays.toString(output));
  24. }
  25. public static void main (String[] args) throws java.lang.Exception
  26. {
  27. test1();
  28. test2();
  29. }
  30. }
Success #stdin #stdout 0.06s 380672KB
stdin
Standard input is empty
stdout
len=0 [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
len=12 [120, -38, 75, -54, 73, -52, 0, 0, 3, -6, 1, -104, 0, 0, 0, 0, 0, 0, 0, 0]