view src/cachingfilter/BufferInputStream.java @ 43:4d90d48a19ec

fix init example
author Vadim Filimonov <fffilimonov@yandex.ru>
date Fri, 11 Jun 2021 15:28:26 +0300
parents 7ecd1a4ef557
children
line wrap: on
line source

package cachingfilter;

import java.io.InputStream;
import org.eclipse.jetty.io.Buffer;


public final class BufferInputStream extends InputStream {
	private final Buffer buffer;

	public BufferInputStream(Buffer buffer) {
		this.buffer = buffer;
	}

	public int read() {
		return buffer.length()==0 ? -1 : buffer.get();
	}

	public int read(byte b[], int off, int len) {
		return buffer.get(b,off,len);
	}

	public long skip(long n) {
		return buffer.skip( (int)n );
	}

	public int available() {
		return buffer.length();
	}

	public void mark(int readlimit) {
		buffer.mark();
	}

	public void reset() {
		buffer.reset();
	}

	public boolean markSupported() {
		return true;
	}
}