title: java parse binary file and convert to hex
body: <p><strong>Please read my question carefully, then judge if it is duplicate</strong></p>
  
  <p><strong>I am green. If there is any mistake in my description please help me figure it out</strong></p>
  
  <p>I want to parse a binary file by java. the first pic is the file opened by hex editor, you can see from 000000 0 to 000000 3 is <strong>ef ef ef ef</strong> </p>
  
  <p><a href="https://i.stack.imgur.com/5ctV2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5ctV2.png" alt="enter image description here"></a></p>
  
  <p>here is my code </p>
  
  <pre><code>String filepath = "D:\\CHR_2_20151228132500.dat.gz";
  File file = new File(filepath);
  FileInputStream fis = new FileInputStream(file);
  
  GZIPInputStream gzip = new GZIPInputStream(fis);
  
  DataInputStream din = new DataInputStream(gzip);
  
  byte[] bytes = new byte[20];
  
  din.read(bytes, 0, 4);
  
  for (byte b : bytes) {
      String str  = Integer.toHexString(b);
      System.out.print(str);
  }
  </code></pre>
  
  <p>this is the result I parse you can see there is <strong>ffffff</strong> between each <strong>ef</strong>  and several zero appended</p>
  
  <p><a href="https://i.stack.imgur.com/Pd1Y2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Pd1Y2.png" alt="enter image description here"></a></p>
  
  <p>I want get data as same as it in hex editor.how can I get this ?</p>