All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jolokia.docker.maven.access.chunked.ChunkedResponseReader Maven / Gradle / Ivy

There is a newer version: 0.13.9
Show newest version
package org.jolokia.docker.maven.access.chunked;

import org.jolokia.docker.maven.access.DockerAccessException;

import java.io.IOException;
import java.io.InputStream;

public class ChunkedResponseReader {

    private final InputStream stream;
    private final ChunkedResponseHandler handler;
    
    public ChunkedResponseReader(InputStream stream, ChunkedResponseHandler handler) {
        this.stream = stream;
        this.handler = handler;
    }        
    
    public void process() throws IOException, DockerAccessException {
        int len;
        int size = 8129;
        byte[] buf = new byte[size];
        // Data comes in chunkwise
        while ((len = stream.read(buf, 0, size)) != -1) {
            String txt = new String(buf, 0, len, "UTF-8");
            handler.process(txt);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy