title: Decompress GZip string in Java
body: <p>I can find plenty of functions that let you decompress a GZip file, but how do I decompress a GZip string?</p>
  
  <p>I'm trying to parse a HTTP response where the response body is compressed with GZip. However, the entire response is simply stored in a string so part of the string contains binary chars.</p>
  
  <p>I'm attempting to use:</p>
  
  <pre><code>byte responseBodyBytes[] = responseBody.getBytes();
  ByteArrayInputStream bais = new ByteArrayInputStream(responseBodyBytes); 
  GZIPInputStream gzis = new GZIPInputStream(bais);
  </code></pre>
  
  <p>But that just throws an exception: java.io.IOException: Not in GZIP format</p>