title: Byte array lengths with Deflater and Inflater
body: <h3>How do we understand the defined length of the <code>byte array</code>?</h3>
  
  <p>For instance in this example we are defining here that the length of the byte array is 100.</p>
  
  <h3>What if the data that would have to be written to the <code>byte array</code> would be longer than <code>100 bytes</code>?</h3>
  
  <p>The same for the result variable here. I don't understand how these lengths work and how to choose a proper length of a byte array for the needs if you don't know how big your data will be?</p>
  
  <pre><code>try {
           // Encode a String into bytes
           String inputString = "blahblahblah";
           byte[] input = inputString.getBytes("UTF-8");
  
           // Compress the bytes
           **byte[] output = new byte[100];**
           Deflater compresser = new Deflater();
           compresser.setInput(input);
           compresser.finish();
           int compressedDataLength = compresser.deflate(output);
           compresser.end();
  
           // Decompress the bytes
           Inflater decompresser = new Inflater();
           decompresser.setInput(output, 0, compressedDataLength);
           **byte[] result = new byte[100];**
           int resultLength = decompresser.inflate(result);
           decompresser.end();
  
           // Decode the bytes into a String
           String outputString = new String(result, 0, resultLength, "UTF-8");
       } catch(java.io.UnsupportedEncodingException ex) {
           // handle
       } catch (java.util.zip.DataFormatException ex) {
           // handle
       }
  </code></pre>
  
  <p>And for this example, the byte array that is used here as input, is actually called a buffer, how do we understand it?</p>