private byte[] tryDecompress(byte[] in, final int len) throws IOException { if (len > 200000) { throw new IOException("OutOfMemory"); } // Decompress the bytes final byte[] tmp = new byte[len]; final Inflater decompresser = new Inflater(true); decompresser.setInput(in); try { final int resultLength = decompresser.inflate(tmp); if (decompresser.finished() == false) { return null; } decompresser.end(); final byte[] result = copyArray(tmp, resultLength); return result; } catch (DataFormatException e) { // e.printStackTrace(); throw new IOException(e.toString()); } }
public static byte[] decompressZLIB(byte[] input) throws IOException { Inflater decompressor = new Inflater(); decompressor.setInput(input); // Create an expandable byte array to hold the decompressed data ByteArrayOutputStream bos = new ByteArrayOutputStream(input.length); // Decompress the data byte[] buf = new byte[1024]; while (!decompressor.finished()) { try { int count = decompressor.inflate(buf); bos.write(buf, 0, count); } catch (DataFormatException e) { throw new IOException(e.toString()); } } bos.close(); // Get the decompressed data byte[] decompressedData = bos.toByteArray(); return decompressedData; }
/** TIFF Adobe ZIP support contributed by Jason Newton. */ public byte[] zipUncompress(byte[] input) { ByteArrayOutputStream imageBuffer = new ByteArrayOutputStream(); byte[] buffer = new byte[1024]; Inflater decompressor = new Inflater(); decompressor.setInput(input); try { while(!decompressor.finished()) { int rlen = decompressor.inflate(buffer); imageBuffer.write(buffer, 0, rlen); } } catch(DataFormatException e){ IJ.log(e.toString()); } decompressor.end(); return imageBuffer.toByteArray(); }
private byte[] tryDecompress(byte[] in, final int len) throws IOException { // Decompress the bytes final byte[] tmp = new byte[len]; final Inflater decompresser = new Inflater(true); decompresser.setInput(in); try { final int resultLength = decompresser.inflate(tmp); if (decompresser.finished() == false) { return null; } decompresser.end(); final byte[] result = copyArray(tmp, resultLength); return result; } catch (DataFormatException e) { // e.printStackTrace(); throw new IOException(e.toString()); } }
/** TIFF Adobe ZIP support contributed by Jason Newton. */ public byte[] zipUncompress(byte[] input) { ByteArrayOutputStream imageBuffer = new ByteArrayOutputStream(); byte[] buffer = new byte[1024]; Inflater decompressor = new Inflater(); decompressor.setInput(input); try { while(!decompressor.finished()) { int rlen = decompressor.inflate(buffer); imageBuffer.write(buffer, 0, rlen); } } catch(DataFormatException e){ IJ.log(e.toString()); } decompressor.end(); return imageBuffer.toByteArray(); }
private final byte[] uncompress(final byte[] input) throws CorruptIndexException, IOException { // Create an expandable byte array to hold the decompressed data ByteArrayOutputStream bos = new ByteArrayOutputStream(input.length); Inflater decompressor = new Inflater(); try { decompressor.setInput(input); // Decompress the data byte[] buf = new byte[1024]; while (!decompressor.finished()) { try { int count = decompressor.inflate(buf); bos.write(buf, 0, count); } catch (DataFormatException e) { // this will happen if the field is not compressed CorruptIndexException newException = new CorruptIndexException("field data are in wrong format: " + e.toString()); newException.initCause(e); throw newException; } } } finally { decompressor.end(); } // Get the decompressed data return bos.toByteArray(); }
private final byte[] uncompress(final byte[] input) throws CorruptIndexException, IOException { // Create an expandable byte array to hold the decompressed data ByteArrayOutputStream bos = new ByteArrayOutputStream(input.length); Inflater decompressor = new Inflater(); try { decompressor.setInput(input); // Decompress the data byte[] buf = new byte[1024]; while (!decompressor.finished()) { try { int count = decompressor.inflate(buf); bos.write(buf, 0, count); } catch (DataFormatException e) { // this will happen if the field is not compressed CorruptIndexException newException = new CorruptIndexException("field data are in wrong format: " + e.toString()); newException.initCause(e); throw newException; } } } finally { decompressor.end(); } // Get the decompressed data return bos.toByteArray(); }
crc.update(infBuf, 0, inflated); } catch (DataFormatException dfe) { IOException ioe = new IOException(dfe.toString()); ioe.initCause(dfe); throw ioe;
crc.update(infBuf, 0, inflated); } catch (DataFormatException dfe) { IOException ioe = new IOException(dfe.toString()); ioe.initCause(dfe); throw ioe;
throw new IOException(e.toString());
throw new ZipException(e.toString());
getConnection().close(WebSocketConnectionRFC6455.CLOSE_BAD_PAYLOAD,e.toString());
getConnection().close(WebSocketConnectionRFC6455.CLOSE_BAD_PAYLOAD,e.toString());
getConnection().close(WebSocketConnectionRFC6455.CLOSE_BAD_PAYLOAD,e.toString());