title: Exception in thread "main" java.util.zip.DataFormatException: incorrect header check
body: <p>I've written an application in Java for compressing and decompressing a String using Deflaor and Inflator, but when I run it I get the following exception:</p>
  
  <pre><code>Deflated String:x��Q�n�0��@&gt;"C��E����3�,[
  d����9��P������x�O�����hcy��L
  �Ct��{~m�I:�$�%\HD+�I�
  �NwG
  Exception in thread "main" java.util.zip.DataFormatException: incorrect header check
      at java.util.zip.Inflater.inflateBytes(Native Method)
      at java.util.zip.Inflater.inflate(Inflater.java:223)
      at java.util.zip.Inflater.inflate(Inflater.java:240)
      at sample_ftp.Sample_ftp.main(Sample_ftp.java:70)
  Java Result: 1
  </code></pre>
  
  <p>My code:</p>
  
  <pre><code>        // Encode a String into bytes
          String inputString = "Pehla nasha Pehla khumaar Naya pyaar hai naya intezaar Kar loon main kya apna haal Aye dil-e-bekaraar Mere dil-e-bekaraar Tu hi bata Pehla nasha Pehla khumaar Udta hi firoon in hawaon mein kahin Ya main jhool jaoon in ghataon mein kahin Udta hi firoon in hawaon mein kahin Ya main jhool jaoon in ghataon mein kahin Ek kar doon aasmaan zameen Kaho yaaron kya karoon kya nahin Pehla nasha Pehla khumaar Naya pyaar hai naya intezaar Kar loon main kya apna haal Aye dil-e-bekaraar Mere dil-e-bekaraar Tu hi bata Pehla nasha Pehla khumaar Usne baat ki kuchh aise dhang se Sapne de gaya vo hazaaron range ke Usne baat ki kuchh aise dhang se Sapne de gaya vo hazaaron range ke Reh jaoon jaise main haar ke Aur choome vo mujhe pyaar se Pehla nasha Pehla khumaar Naya pyaar hai naya intezaar Kar loon main kya apna haal Aye dil-e-bekaraar Mere dil-e-bekaraar";
          byte[] input = inputString.getBytes("UTF-8");
  
          // Compress the bytes
          byte[] output1 = new byte[100];
          Deflater compresser = new Deflater();
          compresser.setInput(input);
          compresser.finish();
          int compressedDataLength = compresser.deflate(output1);
          compresser.end();
          System.out.println("Deflated String:"+new String(output1));
  
          String str=new String(output1);
          byte output2[]=str.getBytes("UTF-8");
  
           // Decompress the bytes
          Inflater decompresser = new Inflater();
          decompresser.setInput(output2);
          byte[] result = new byte[10000];
          int resultLength = decompresser.inflate(result);
          decompresser.end();
  
          // Decode the bytes into a String
          String outputString = new String(result, 0, resultLength, "UTF-8");
          System.out.println("Deflated String:"+outputString);
  </code></pre>