Example usage for java.util.zip InflaterInputStream available

List of usage examples for java.util.zip InflaterInputStream available

Introduction

In this page you can find the example usage for java.util.zip InflaterInputStream available.

Prototype

public int available() throws IOException 

Source Link

Document

Returns 0 after EOF has been reached, otherwise always return 1.

Usage

From source file:ZipUtil.java

private static void inflaterInputStmToFileOutputStm(InflaterInputStream stmIn, FileOutputStream stmOut)
        throws IOException {
    byte[] buffer = null;
    int iBufferSize = STREAM_BUFFER_SIZE;

    boolean bKeepStreaming = true;
    while (bKeepStreaming) {
        buffer = new byte[iBufferSize];
        int iBytes = stmIn.read(buffer);
        if (iBytes == -1) {
            bKeepStreaming = false;/*from   w ww.jav a  2  s  .  c o m*/
        } else {
            if (iBytes < iBufferSize) {
                bKeepStreaming = false;
                byte[] tmp = new byte[iBytes];
                for (int i = 0; i < iBytes; i++) {
                    tmp[i] = buffer[i];
                }
                buffer = tmp;
            }
            stmOut.write(buffer);
            //Override above test if available returns 1
            if (stmIn.available() == 1) {
                bKeepStreaming = true;
            }
        } //end else some bytes returned.
    } //end while
}