List of usage examples for org.apache.commons.compress.compressors CompressorStreamFactory CompressorStreamFactory
CompressorStreamFactory
From source file:edu.ehu.galan.wiki2wordnet.wikipedia2wordnet.utils.FileUtils.java
/** * Given a String containing a path to a bz2 compressed file returns a bufferedReader with the * contents of the file. The first line will contain the file info, Be warned about this! * * @param fileIn - the file to be processed * @return BufferedReader with the contents of the file * @throws FileNotFoundException/* ww w . ja va 2 s.co m*/ * @throws CompressorException */ public static BufferedReader getBufferedReaderForBZ2File(String fileIn) throws FileNotFoundException, CompressorException { FileInputStream fin = new FileInputStream(fileIn); BufferedInputStream bis = new BufferedInputStream(fin); CompressorInputStream input = new CompressorStreamFactory().createCompressorInputStream(bis); BufferedReader br2 = new BufferedReader(new InputStreamReader(input)); return br2; }
From source file:com.milaboratory.util.CompressionType.java
private static InputStream createInputStream(CompressionType ct, InputStream is) throws IOException { switch (ct) { case None:/*w w w.jav a2s . co m*/ return is; case GZIP: return new GZIPInputStream(is, 2048); case BZIP2: CompressorStreamFactory factory = new CompressorStreamFactory(); try { return factory.createCompressorInputStream(CompressorStreamFactory.BZIP2, new BufferedInputStream(is)); } catch (CompressorException e) { throw new IOException(e); } } throw new NullPointerException(); }
From source file:net.ovres.util.UncompressedInputStream.java
/** * Returns a decompressed version of the given input stream. * This is done for any set //ww w .j a v a 2 s. c o m * * @param raw the raw input stream * @return the decompressed version of <tt>raw</tt> */ public static InputStream convertStream(InputStream raw) throws IOException { if (!raw.markSupported()) { raw = new BufferedInputStream(raw); } try { return new CompressorStreamFactory().createCompressorInputStream(raw); } catch (CompressorException e) { // Assume this is because of an unknown compression type. // That's ok, it might not be compressed. return raw; } }
From source file:com.github.n_i_e.dirtreedb.ApacheCompressCompressorLister.java
public ApacheCompressCompressorLister(PathEntry basepath, InputStream inf) throws IOException { super(basepath, inf); try {//from www . j av a2 s. com setInstream(new CompressorStreamFactory().createCompressorInputStream(inf)); } catch (CompressorException e) { throw new IOException(e.toString()); } }
From source file:com.wrmsr.kleist.codec.stream.CompressorStreamCodec.java
@Override public InputStream decode(InputStream inputStream) throws IOException { try {/*w ww .j a v a2 s. c o m*/ return new CompressorStreamFactory().createCompressorInputStream(name, inputStream); } catch (CompressorException e) { throw Throwables.propagate(e); } }
From source file:com.milaboratory.core.io.CompressionType.java
private static InputStream createInputStream(CompressionType ct, InputStream is, int buffer) throws IOException { switch (ct) { case None:/*from www.ja va 2 s .c o m*/ return is; case GZIP: return new GZIPInputStream(is, buffer); case BZIP2: CompressorStreamFactory factory = new CompressorStreamFactory(); try { return factory.createCompressorInputStream(CompressorStreamFactory.BZIP2, new BufferedInputStream(is)); } catch (CompressorException e) { throw new IOException(e); } } throw new NullPointerException(); }
From source file:com.milaboratory.util.CompressionType.java
private static OutputStream createOutputStream(CompressionType ct, OutputStream os) throws IOException { switch (ct) { case None:// www . j a v a 2 s. c o m return os; case GZIP: return new GZIPOutputStream(os, 2048); case BZIP2: CompressorStreamFactory factory = new CompressorStreamFactory(); try { return factory.createCompressorOutputStream(CompressorStreamFactory.BZIP2, new BufferedOutputStream(os)); } catch (CompressorException e) { throw new IOException(e); } } throw new NullPointerException(); }
From source file:com.wrmsr.kleist.codec.stream.CompressorStreamCodec.java
@Override public OutputStream encode(OutputStream outputStream) throws IOException { try {//from w w w . j a v a2 s . c o m return new CompressorStreamFactory().createCompressorOutputStream(name, outputStream); } catch (CompressorException e) { throw Throwables.propagate(e); } }
From source file:com.github.n_i_e.dirtreedb.ApacheCompressCompressingArchiveLister.java
public ApacheCompressCompressingArchiveLister(PathEntry basepath, InputStream inf) throws IOException { super(basepath); Assertion.assertNullPointerException(inf != null); try {//w ww . j a v a2s .c om InputStream inf2 = new CompressorStreamFactory().createCompressorInputStream(inf); InputStream inf3 = new BufferedInputStream(inf2); assert (inf3.markSupported()); instream = new ArchiveStreamFactory().createArchiveInputStream(inf3); } catch (ArchiveException e) { throw new IOException(e.toString()); } catch (CompressorException e) { throw new IOException(e.toString()); } }
From source file:net.sf.util.zip.analyzer.CompressorAnalyzer.java
private CompressorInputStream getCompressedInputStream(String type, InputStream stream) throws Exception { stream = new ProxyInputStream(stream); CompressorInputStream newCInputStream = (type == null) ? new CompressorStreamFactory().createCompressorInputStream(stream) : new CompressorStreamFactory().createCompressorInputStream(type, stream); return newCInputStream; }