title: How to convert Java String into byte[]?
body: <p>Is there any way to convert Java <code>String</code> to a <code>byte[]</code> (<em>not</em> the boxed <code>Byte[]</code>)?</p>
  
  <p>In trying this:</p>
  
  <pre><code>System.out.println(response.split("\r\n\r\n")[1]);
  System.out.println("******");
  System.out.println(response.split("\r\n\r\n")[1].getBytes().toString());
  </code></pre>
  
  <p>and I'm getting separate outputs. Unable to display 1st output as it is a gzip string.</p>
  
  <pre><code>&lt;A Gzip String&gt;
  ******
  [B@38ee9f13
  </code></pre>
  
  <p>The second is an address. Is there anything I'm doing wrong? I need the result in a <code>byte[]</code> to feed it to gzip decompressor, which is as follows.</p>
  
  <pre><code>String decompressGZIP(byte[] gzip) throws IOException {
      java.util.zip.Inflater inf = new java.util.zip.Inflater();
      java.io.ByteArrayInputStream bytein = new java.io.ByteArrayInputStream(gzip);
      java.util.zip.GZIPInputStream gzin = new java.util.zip.GZIPInputStream(bytein);
      java.io.ByteArrayOutputStream byteout = new java.io.ByteArrayOutputStream();
      int res = 0;
      byte buf[] = new byte[1024];
      while (res &gt;= 0) {
          res = gzin.read(buf, 0, buf.length);
          if (res &gt; 0) {
              byteout.write(buf, 0, res);
          }
      }
      byte uncompressed[] = byteout.toByteArray();
      return (uncompressed.toString());
  }
  </code></pre>