public static String stripCompressionExtension(String aLocation) { String lcLocation = aLocation.toLowerCase(); if (lcLocation.endsWith(GZIP.getExtension())) { return aLocation.substring(0, GZIP.getExtension().length()); } else if (lcLocation.endsWith(BZIP2.getExtension()) || lcLocation.endsWith(".bzip2")) { return aLocation.substring(0, BZIP2.getExtension().length()); } else if (lcLocation.endsWith(".bzip2")) { return aLocation.substring(0, ".bzip2".length()); } else if (lcLocation.endsWith(XZ.getExtension())) { return aLocation.substring(0, XZ.getExtension().length()); } else { return aLocation; } }
/** * Get an uncompressed input stream for a given input stream created for a particular location. * * @param aLocation * a resource location (e.g. a path, URL, etc.) * @param aStream * a raw stream of potentially compressed data. * @return stream wrapped with a decompressing stream. * @throws IOException if an I/O error has occurred, */ public static InputStream getInputStream(String aLocation, InputStream aStream) throws IOException { String lcLocation = aLocation.toLowerCase(); if (lcLocation.endsWith(GZIP.getExtension())) { return new GZIPInputStream(aStream); } else if (lcLocation.endsWith(BZIP2.getExtension()) || lcLocation.endsWith(".bzip2")) { return new BZip2CompressorInputStream(aStream); } else if (lcLocation.endsWith(XZ.getExtension())) { return new XZCompressorInputStream(aStream); } else { return aStream; } }
if (lcFilename.endsWith(GZIP.getExtension())) { os = new GZIPOutputStream(os); else if (lcFilename.endsWith(BZIP2.getExtension()) || lcFilename.endsWith(".bzip2")) { os = new BZip2CompressorOutputStream(os); else if (lcFilename.endsWith(XZ.getExtension())) { os = new XZCompressorOutputStream(os);
+ compression.getExtension()); zipOutputStream.putNextEntry(entry); + compression.getExtension());
+ compression.getExtension()); zipOutputStream.putNextEntry(entry); + compression.getExtension());