Search in sources :

Example 6 with CompressException

use of com.alibaba.otter.node.etl.common.io.compress.exception.CompressException in project otter by alibaba.

the class AbstractCompressor method compressTo.

public void compressTo(File input, File output) throws CompressException {
    FileOutputStream outputStream = null;
    FileInputStream inputStream = null;
    try {
        outputStream = new FileOutputStream(output);
        inputStream = new FileInputStream(input);
        this.compressTo(inputStream, outputStream);
    } catch (FileNotFoundException e) {
        throw new CompressException("File not found", e);
    } finally {
        IOUtils.closeQuietly(inputStream);
        IOUtils.closeQuietly(outputStream);
    }
}
Also used : FileOutputStream(java.io.FileOutputStream) FileNotFoundException(java.io.FileNotFoundException) FileInputStream(java.io.FileInputStream) CompressException(com.alibaba.otter.node.etl.common.io.compress.exception.CompressException)

Example 7 with CompressException

use of com.alibaba.otter.node.etl.common.io.compress.exception.CompressException in project otter by alibaba.

the class AbstractCompressor method decompress.

public InputStream decompress(File input) throws CompressException {
    File temp = null;
    InputStream result = null;
    try {
        temp = File.createTempFile("compress_", "jkt");
        this.decompressTo(input, temp);
        result = new FileInputStream(temp);
    } catch (IOException e) {
        throw new CompressException("Error while creating a temporary file", e);
    }
    return result;
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) IOException(java.io.IOException) File(java.io.File) FileInputStream(java.io.FileInputStream) CompressException(com.alibaba.otter.node.etl.common.io.compress.exception.CompressException)

Example 8 with CompressException

use of com.alibaba.otter.node.etl.common.io.compress.exception.CompressException in project otter by alibaba.

the class AbstractCompressor method decompressTo.

public void decompressTo(File input, File output) throws CompressException {
    FileInputStream inputStream = null;
    FileOutputStream outputStream = null;
    try {
        outputStream = new FileOutputStream(output);
        inputStream = new FileInputStream(input);
        decompressTo(inputStream, outputStream);
    } catch (FileNotFoundException e) {
        throw new CompressException("File could not be found", e);
    } finally {
        IOUtils.closeQuietly(inputStream);
        IOUtils.closeQuietly(outputStream);
    }
}
Also used : FileOutputStream(java.io.FileOutputStream) FileNotFoundException(java.io.FileNotFoundException) FileInputStream(java.io.FileInputStream) CompressException(com.alibaba.otter.node.etl.common.io.compress.exception.CompressException)

Example 9 with CompressException

use of com.alibaba.otter.node.etl.common.io.compress.exception.CompressException in project otter by alibaba.

the class AbstractCompressor method decompress.

public InputStream decompress(InputStream input) throws CompressException {
    File temp = null;
    InputStream result = null;
    FileOutputStream output = null;
    try {
        temp = File.createTempFile("compress_", "jkt");
        output = new FileOutputStream(temp);
        this.decompressTo(input, output);
        result = new FileInputStream(temp);
    } catch (IOException e) {
        throw new CompressException("Error while creating a temporary file", e);
    } finally {
        IOUtils.closeQuietly(output);
    }
    return result;
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) File(java.io.File) FileInputStream(java.io.FileInputStream) CompressException(com.alibaba.otter.node.etl.common.io.compress.exception.CompressException)

Aggregations

CompressException (com.alibaba.otter.node.etl.common.io.compress.exception.CompressException)9 FileInputStream (java.io.FileInputStream)5 FileOutputStream (java.io.FileOutputStream)4 File (java.io.File)3 IOException (java.io.IOException)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 FileNotFoundException (java.io.FileNotFoundException)2 InputStream (java.io.InputStream)2 GZIPInputStream (java.util.zip.GZIPInputStream)1 GZIPOutputStream (java.util.zip.GZIPOutputStream)1 BZip2CompressorInputStream (org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream)1 BZip2CompressorOutputStream (org.apache.commons.compress.compressors.bzip2.BZip2CompressorOutputStream)1