United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-2192186 GZIPInputStream fails to read concatenated .gz files
JDK-2192186 : GZIPInputStream fails to read concatenated .gz files

Details
Type:
Backport
Submit Date:
2010-04-26
Status:
Closed
Updated Date:
2011-02-16
Project Name:
JDK
Resolved Date:
2010-08-03
Component:
core-libs
OS:
Sub-Component:
java.util.jar
CPU:
Priority:
P2
Resolution:
Fixed
Affected Versions:
Fixed Versions:
6u21-rev (b08)

Related Reports
Backport:

Sub Tasks

Description
                                    

Comments
WORK AROUND

import java.io.LineNumberReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.FileInputStream;
import java.io.PushbackInputStream;
import java.util.zip.GZIPInputStream;

public class test extends GZIPInputStream {

	public test(InputStream is) 
	throws java.io.IOException {
       super(is);
    }

	public int readConcatGZ()
	throws java.io.IOException {
			//send in file path as arg[0]
			InputStreamReader isr = new InputStreamReader(this);
			LineNumberReader lnr = new LineNumberReader(isr);
			String line;
			while((line = lnr.readLine()) != null) {
				System.out.println(line);
		    }

		    int rem = inf.getRemaining();
			rem -= 8;
			if (rem > 1){
		       ((PushbackInputStream) in).unread(buf,len-rem,rem);
			   inf.reset();
			}

			return rem;
	}

    public static void main (String[] args) {
		try{
			FileInputStream fis = new FileInputStream( args[0] );
			PushbackInputStream pis = new PushbackInputStream(fis, 1024);
			int n;
			do{
		       test t = new test(pis);
			   n = t.readConcatGZ();
			}while(n > 0);
		}
		catch(Throwable e){
			System.err.println(e);
			e.printStackTrace();
		}
    }
}
                                     
2010-04-29
EVALUATION

see parent CR
                                     
2010-06-03



Hardware and Software, Engineered to Work Together