2 Replies Latest reply on Jan 13, 2011 11:12 PM by 831072

    GZIPInputStream returning EOF after only 62k read


      I'm trying to get a darn gzip file read, and it ends after 62k. I've tried many combinations of streams and readers, all the way down to just using a GZIPInputStream(new FileInputStream(filename)) and reading byte by byte.

      I keep running into '-1' after about 62k bytes have been read. I'm assuming it's because a buffer somewhere ends at 62k, but I've tried setting the buffer to a larger size with the same result.

      I want to read line by line...

      package test;

      import java.io.InputStreamReader;
      import java.io.FileInputStream;
      import java.io.FileNotFoundException;
      import java.io.IOException;
      import java.io.LineNumberReader;
      import java.util.zip.GZIPInputStream;

      public class GZipReadTest2 {
                private static final String FILE = "myfile.gz";
                private static LineNumberReader lnr;

                public static void main(String[] args) throws FileNotFoundException, IOException {
                     lnr = new LineNumberReader(
                               new InputStreamReader(
                               new GZIPInputStream(
                               new FileInputStream(FILE))));

                     String line = "start";
                     while((line = lnr.readLine()) != null) {
                          try {
                          } catch (IOException e) {
                     System.out.println("Done reading " + FILE + " at line: " + lnr.getLineNumber());