How do I handle disparate OSes to avoid "Unexpected end of ZLIB input stream"

  eof, gzip, java, linux, windows

I have a log analyzing tool that needs to grab *.gz files from Linux servers and unzip them on both Linux and Windows clients. I am getting "Unexpected end of ZLIB input stream" in many instances, which I assume is a difference in detail in the files on Linux and Windows.

Below is my function. It’s pretty basic. How do I improved it to prevent the EOF error?

The "in" symbol is a FileInputStream that is created when constructing the class that this function is part of.

public void unzip(File fileTo) throws IOException {
    OutputStream out = new FileOutputStream(fileTo);"Setting up the file for outputstream : "+fileTo);
    try {
      in = new GZIPInputStream(in);
      byte[] buffer = new byte[65536];
      int noRead;
      while ((noRead = != -1) {
          out.write(buffer, 0, noRead);
    } finally {
        try { out.close(); } catch (Exception e) {}

Source: Windows Questions