Class Compression

java.lang.Object
com.jcraft.jsch.juz.Compression
All Implemented Interfaces:
Compression

public class Compression extends Object implements Compression
This example demonstrates the packet compression without using jzlib[1].

The ssh protocol adopts zlib[2] for the packet compression. Fortunately, JDK has provided wrapper classes for zlib(j.u.z.{Deflater, Inflater}), but it does not expose enough functionality of zlib, unfortunately; it must not allow to compress data with SYNC_FLUSH. So, JSch has been using jzlib by the default. After 12 years of bug parade entry[3] filing, Java7 has revised j.u.z.Deflater, and SYNC_FLUSH has been supported at last. This example shows how to enable the packet compression by using JDK's java.util.zip package.

[1] http://www.jcraft.com/jzlib/ [2] http://www.zlib.net/ [3] https://bugs.openjdk.java.net/browse/JDK-4206909

  • Constructor Details

    • Compression

      public Compression()
  • Method Details

    • end

      public void end()
      Specified by:
      end in interface Compression
    • init

      public void init(int type, int level, Session session)
      Specified by:
      init in interface Compression
    • init

      public void init(int type, int level)
      Specified by:
      init in interface Compression
    • compress

      public byte[] compress(byte[] buf, int start, int[] end)
      Specified by:
      compress in interface Compression
    • uncompress

      public byte[] uncompress(byte[] buf, int start, int[] len)
      Specified by:
      uncompress in interface Compression