use of com.alibaba.otter.node.etl.common.io.compress.exception.CompressException in project otter by alibaba.
the class BZip2Compressor method decompressTo.
public void decompressTo(InputStream in, OutputStream out) throws CompressException {
BZip2CompressorInputStream inputStream = null;
try {
inputStream = new BZip2CompressorInputStream(in);
NioUtils.copy(inputStream, out);
} catch (Exception e) {
throw new CompressException("bzip_decompress_error", e);
}
}
use of com.alibaba.otter.node.etl.common.io.compress.exception.CompressException in project otter by alibaba.
the class BZip2Compressor method compressTo.
public void compressTo(InputStream in, OutputStream out) throws CompressException {
BZip2CompressorOutputStream outputBZStream = null;
try {
outputBZStream = new BZip2CompressorOutputStream(out);
NioUtils.copy(in, outputBZStream);
outputBZStream.finish();
} catch (Exception e) {
throw new CompressException("bzip_compress_error", e);
}
}
use of com.alibaba.otter.node.etl.common.io.compress.exception.CompressException in project otter by alibaba.
the class GzipCompressor method compressTo.
public void compressTo(InputStream in, OutputStream out) throws CompressException {
GZIPOutputStream gzipOut = null;
try {
gzipOut = new GZIPOutputStream(out);
NioUtils.copy(in, gzipOut);
//需要使用finish
gzipOut.finish();
} catch (Exception e) {
throw new CompressException("gzip_compress_error", e);
}
}
use of com.alibaba.otter.node.etl.common.io.compress.exception.CompressException in project otter by alibaba.
the class GzipCompressor method decompressTo.
public void decompressTo(InputStream in, OutputStream out) throws CompressException {
GZIPInputStream gzipin = null;
try {
gzipin = new GZIPInputStream(in);
NioUtils.copy(gzipin, out);
out.flush();
} catch (Exception e) {
throw new CompressException("gzip_decompress_error", e);
}
}
use of com.alibaba.otter.node.etl.common.io.compress.exception.CompressException in project otter by alibaba.
the class AbstractCompressor method compress.
public InputStream compress(InputStream input) throws CompressException {
FileOutputStream output = null;
try {
File temp = File.createTempFile("compress_", "jkt");
output = new FileOutputStream(temp);
//转化为流进行处理
compressTo(input, output);
return new FileInputStream(temp);
} catch (IOException e) {
throw new CompressException("An I/O Exception has occured", e);
} finally {
IOUtils.closeQuietly(output);
}
}
Aggregations