xhtml.startDocument();
// At the end we want to close the bzip2 stream to release any associated
// resources, but the underlying document stream should not be closed
InputStream gzip =
new CBZip2InputStream(new CloseShieldInputStream(stream));
try {
Metadata entrydata = new Metadata();
String name = metadata.get(Metadata.RESOURCE_NAME_KEY);
if (name != null) {
if (name.endsWith(".tbz")) {
name = name.substring(0, name.length() - 4) + ".tar";
} else if (name.endsWith(".tbz2")) {
name = name.substring(0, name.length() - 5) + ".tar";
} else if (name.endsWith(".bz")) {
name = name.substring(0, name.length() - 3);
} else if (name.endsWith(".bz2")) {
name = name.substring(0, name.length() - 4);
}
entrydata.set(Metadata.RESOURCE_NAME_KEY, name);
}
parseEntry(gzip, xhtml, entrydata);
} finally {
gzip.close();
}
xhtml.endDocument();
}