Java Code Examples for com.jcraft.jzlib.JZlib#Z_BUF_ERROR
The following examples show how to use
com.jcraft.jzlib.JZlib#Z_BUF_ERROR .
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: RpcGZIPOutputStream.java From p4ic4idea with Apache License 2.0 | 6 votes |
/** * Provide a more human-readable form of the underlying JZlib compression errors.<p> * * Should be made even more human-readable sometime later -- HR. */ protected String getJZlibErrorStr(int errNum) { switch (errNum) { case JZlib.Z_STREAM_ERROR: return "stream error"; case JZlib.Z_DATA_ERROR: return "data error"; case JZlib.Z_MEM_ERROR: return "memory error"; case JZlib.Z_BUF_ERROR: return "buffer error"; case JZlib.Z_VERSION_ERROR: return "version error"; default: return "unknown error"; } }
Example 2
Source File: RpcGZIPOutputStream.java From p4ic4idea with Apache License 2.0 | 6 votes |
/** * Provide a more human-readable form of the underlying JZlib compression errors.<p> * * Should be made even more human-readable sometime later -- HR. */ protected String getJZlibErrorStr(int errNum) { switch (errNum) { case JZlib.Z_STREAM_ERROR: return "stream error"; case JZlib.Z_DATA_ERROR: return "data error"; case JZlib.Z_MEM_ERROR: return "memory error"; case JZlib.Z_BUF_ERROR: return "buffer error"; case JZlib.Z_VERSION_ERROR: return "version error"; default: return "unknown error"; } }
Example 3
Source File: RpcGZIPOutputStream.java From p4ic4idea with Apache License 2.0 | 6 votes |
/** * Provide a more human-readable form of the underlying JZlib compression errors.<p> * * Should be made even more human-readable sometime later -- HR. */ protected String getJZlibErrorStr(int errNum) { switch (errNum) { case JZlib.Z_STREAM_ERROR: return "stream error"; case JZlib.Z_DATA_ERROR: return "data error"; case JZlib.Z_MEM_ERROR: return "memory error"; case JZlib.Z_BUF_ERROR: return "buffer error"; case JZlib.Z_VERSION_ERROR: return "version error"; default: return "unknown error"; } }
Example 4
Source File: RpcGZIPOutputStream.java From p4ic4idea with Apache License 2.0 | 6 votes |
/** * Provide a more human-readable form of the underlying JZlib compression errors.<p> * * Should be made even more human-readable sometime later -- HR. */ protected String getJZlibErrorStr(int errNum) { switch (errNum) { case JZlib.Z_STREAM_ERROR: return "stream error"; case JZlib.Z_DATA_ERROR: return "data error"; case JZlib.Z_MEM_ERROR: return "memory error"; case JZlib.Z_BUF_ERROR: return "buffer error"; case JZlib.Z_VERSION_ERROR: return "version error"; default: return "unknown error"; } }
Example 5
Source File: RpcGZIPOutputStream.java From p4ic4idea with Apache License 2.0 | 6 votes |
/** * Provide a more human-readable form of the underlying JZlib compression errors.<p> * * Should be made even more human-readable sometime later -- HR. */ protected String getJZlibErrorStr(int errNum) { switch (errNum) { case JZlib.Z_STREAM_ERROR: return "stream error"; case JZlib.Z_DATA_ERROR: return "data error"; case JZlib.Z_MEM_ERROR: return "memory error"; case JZlib.Z_BUF_ERROR: return "buffer error"; case JZlib.Z_VERSION_ERROR: return "version error"; default: return "unknown error"; } }
Example 6
Source File: RpcGZIPOutputStream.java From p4ic4idea with Apache License 2.0 | 6 votes |
/** * Provide a more human-readable form of the underlying JZlib compression errors.<p> * * Should be made even more human-readable sometime later -- HR. */ protected String getJZlibErrorStr(int errNum) { switch (errNum) { case JZlib.Z_STREAM_ERROR: return "stream error"; case JZlib.Z_DATA_ERROR: return "data error"; case JZlib.Z_MEM_ERROR: return "memory error"; case JZlib.Z_BUF_ERROR: return "buffer error"; case JZlib.Z_VERSION_ERROR: return "version error"; default: return "unknown error"; } }
Example 7
Source File: ZLibCompression.java From j2ssh-maverick with GNU Lesser General Public License v3.0 | 5 votes |
public byte[] uncompress(byte[] buffer, int start, int length) throws IOException { // int inflated_end = 0; uncompressOut.reset(); stream.next_in = buffer; stream.next_in_index = start; stream.avail_in = length; while (true) { stream.next_out = inflated_buf; stream.next_out_index = 0; stream.avail_out = BUF_SIZE; int status = stream.inflate(JZlib.Z_PARTIAL_FLUSH); switch (status) { case JZlib.Z_OK: uncompressOut.write(inflated_buf, 0, BUF_SIZE - stream.avail_out); break; case JZlib.Z_BUF_ERROR: return uncompressOut.toByteArray(); default: throw new IOException("uncompress: inflate returnd " + status); } } }
Example 8
Source File: Zlib.java From neoscada with Eclipse Public License 1.0 | 4 votes |
/** * Uncompress the given buffer, returning it in a new buffer. * * @param inBuffer the {@link IoBuffer} to be decompressed. The contents * of the buffer are transferred into a local byte array and the buffer is * flipped and returned intact. * @return the decompressed data * @throws IOException if the decompression of the data failed for some reason. * @throws IllegalArgumentException if the mode is not <code>MODE_DEFLATER</code> */ public IoBuffer inflate(IoBuffer inBuffer) throws IOException { if (mode == MODE_DEFLATER) { throw new IllegalStateException("not initialized as INFLATER"); } byte[] inBytes = new byte[inBuffer.remaining()]; inBuffer.get(inBytes).flip(); // We could probably do this better, if we're willing to return multiple buffers // (e.g. with a callback function) byte[] outBytes = new byte[inBytes.length * 2]; IoBuffer outBuffer = IoBuffer.allocate(outBytes.length); outBuffer.setAutoExpand(true); synchronized (zStream) { zStream.next_in = inBytes; zStream.next_in_index = 0; zStream.avail_in = inBytes.length; zStream.next_out = outBytes; zStream.next_out_index = 0; zStream.avail_out = outBytes.length; int retval = 0; do { retval = zStream.inflate(JZlib.Z_SYNC_FLUSH); switch (retval) { case JZlib.Z_OK: // completed decompression, lets copy data and get out case JZlib.Z_BUF_ERROR: // need more space for output. store current output and get more outBuffer.put(outBytes, 0, zStream.next_out_index); zStream.next_out_index = 0; zStream.avail_out = outBytes.length; break; default: // unknown error outBuffer = null; if (zStream.msg == null) { throw new IOException("Unknown error. Error code : " + retval); } else { throw new IOException("Unknown error. Error code : " + retval + " and message : " + zStream.msg); } } } while (zStream.avail_in > 0); } return outBuffer.flip(); }