title: How to print raw byte content from a byte[] array to stdout in Java?
body: <p>I am doing the same project as describe here:</p>
  
  <p><a href="https://stackoverflow.com/questions/13105481/wrap-deflated-data-in-gzip-format">Wrap deflated data in gzip format</a></p>
  
  <p>My problem is that when I try to print out bytes, I get weird results. My problems occur in the following code(Sorry for my bad choice of variables):</p>
  
  <pre><code>    for(int k = 0; k &lt; head.length; k++){
          System.out.write(head[k]);
      }
  
      for(int m = 0; m &lt; a.size(); m++){
          int comprlength = a.get(m).getclength();
          for(int ii = 0; ii &lt; comprlength; ii++){
              System.out.write(a.get(m).getcompr()[ii]);
          }
      }
      for(int j = 0; j &lt; f1.length; j++){
          System.out.write(f1[j]);
      }
      for(int ll = 0; ll &lt; total_d.length; ll++){
          System.out.write(total_d[ll]);
      }
  </code></pre>
  
  <p>The last two for-loops do not print out the contents of the their byte arrays. Thus I get a unexpected end of file error when using gzip. The weird thing is that if I comment out the second for-loop block (the block with the variables m and ii), nothing gets printed out.</p>
  
  <p>So how do I properly print out the contents of my byte arrays? Why does the first for-loop print out properly when the second for-loop is not commented and why does it not print anything if that second for-loop is commented?</p>
  
  <p>EDIT:</p>
  
  <p>To be more specific:</p>
  
  <p>I want to write out the raw bytes. And I want to do it so that it is right after each other for every one of my byte arrays</p>