title: Exception: Unexpected end of ZLIB input stream
body: <p>There is something wrong with <code>GZIPInputStream</code> or <code>GZIPOutputStream</code>. Just please read the following code (or run it and see what happens):</p>
  
  <pre><code>def main(a: Array[String]) {
      val name = "test.dat"
      new GZIPOutputStream(new FileOutputStream(name)).write(10)
      println(new GZIPInputStream(new FileInputStream(name)).read())
  }
  </code></pre>
  
  <p>It creates a file <code>test.dat</code>, writes a single byte <code>10</code> formatting by GZIP, and read the byte in the same file with the same format.</p>
  
  <p>And this is what I got running it:</p>
  
  <pre><code>Exception in thread "main" java.io.EOFException: Unexpected end of ZLIB input stream
      at java.util.zip.InflaterInputStream.fill(Unknown Source)
      at java.util.zip.InflaterInputStream.read(Unknown Source)
      at java.util.zip.GZIPInputStream.read(Unknown Source)
      at java.util.zip.InflaterInputStream.read(Unknown Source)
      at nbt.Test$.main(Test.scala:13)
      at nbt.Test.main(Test.scala)
  </code></pre>
  
  <p>The reading line seems going the wrong way for some reason.</p>
  
  <p>I googled the error <code>Unexpected end of ZLIB input stream</code> and found some bug reports to Oracle, which were issued around 2007-2010. So I guess the bug still remains in some way, but I'm not sure if my code is right, so let me post this here and listen to your advice. Thank you!</p>