Java Code Examples for org.apache.commons.compress.compressors.bzip2.BZip2CompressorOutputStream#write()
The following examples show how to use
org.apache.commons.compress.compressors.bzip2.BZip2CompressorOutputStream#write() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Bzip2DecoderTest.java From netty-4.1.22 with Apache License 2.0 | 5 votes |
@Override protected byte[] compress(byte[] data) throws Exception { ByteArrayOutputStream os = new ByteArrayOutputStream(); BZip2CompressorOutputStream bZip2Os = new BZip2CompressorOutputStream(os, MIN_BLOCK_SIZE); bZip2Os.write(data); bZip2Os.close(); return os.toByteArray(); }
Example 2
Source File: ArchivePrinter.java From steady with Apache License 2.0 | 5 votes |
/** * It reads data from a an input file, then write and compress to a bzip2 file using BZip2CompressorOutputStream * If a special input file with repeating inputs is provided, the vulnerability in BZip2CompressorOutputStream will result in endless writing and consuming lots of resources * Please refer to https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2012-2098 * @param _in * @param _out * @throws Exception */ public static void compressExploitability(Path _in, Path _out) throws Exception { FileInputStream fin = new FileInputStream(_in.toString()); BufferedInputStream in = new BufferedInputStream(fin); BZip2CompressorOutputStream out = new BZip2CompressorOutputStream(new FileOutputStream(_out.toString())); BZip2CompressorInputStream bzIn = new BZip2CompressorInputStream(in); final byte[] buffer = new byte[1024*10]; int n = 0; while (-1 != (n = bzIn.read(buffer))) { out.write(buffer, 0, n); } out.close(); bzIn.close(); }
Example 3
Source File: ArchivePrinter.java From steady with Apache License 2.0 | 5 votes |
/** * It reads data from a an input file, then write and compress to a bzip2 file using BZip2CompressorOutputStream * If a special input file with repeating inputs is provided, the vulnerability in BZip2CompressorOutputStream will result in endless writing and consuming lots of resources * Please refer to https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2012-2098 * @param _in * @param _out * @throws Exception */ public static void compressExploitability(Path _in, Path _out) throws Exception { FileInputStream fin = new FileInputStream(_in.toString()); BufferedInputStream in = new BufferedInputStream(fin); BZip2CompressorOutputStream out = new BZip2CompressorOutputStream(new FileOutputStream(_out.toString())); BZip2CompressorInputStream bzIn = new BZip2CompressorInputStream(in); final byte[] buffer = new byte[1024*10]; int n = 0; while (-1 != (n = bzIn.read(buffer))) { out.write(buffer, 0, n); } out.close(); bzIn.close(); }
Example 4
Source File: Bzip2Compress.java From compress with MIT License | 5 votes |
@Override public byte[] compress(byte[] data) throws IOException { ByteArrayOutputStream out = new ByteArrayOutputStream(); BZip2CompressorOutputStream bcos = new BZip2CompressorOutputStream(out); bcos.write(data); bcos.close(); return out.toByteArray(); }
Example 5
Source File: CompressTest.java From JQF with BSD 2-Clause "Simplified" License | 5 votes |
@Fuzz public void bzip2(byte @Size(min=100, max=100)[] bytes){ OutputStream o = new ByteArrayOutputStream(); try { BZip2CompressorOutputStream bo = new BZip2CompressorOutputStream(o); bo.write(bytes); bo.finish(); } catch (IOException e){ Assume.assumeNoException(e); } }
Example 6
Source File: RepoBuilder.java From packagedrone with Eclipse Public License 1.0 | 5 votes |
private byte[] compressBzip2 ( final byte[] data ) throws IOException { final ByteArrayOutputStream bos = new ByteArrayOutputStream (); final BZip2CompressorOutputStream b2os = new BZip2CompressorOutputStream ( bos ); b2os.write ( data ); b2os.close (); return bos.toByteArray (); }