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

org.jclarion.clarion.util.SharedReader Maven / Gradle / Ivy

There is a newer version: 1.86
Show newest version
package org.jclarion.clarion.util;

import java.io.IOException;
import java.io.Reader;

public class SharedReader extends Reader
{
	private char buffer[];
	private int len;
	private int pos;
	private int mark;
	
	public SharedReader(char buffer[],int len)
	{
		this.buffer=buffer;
		this.len=len;
	}

	@Override
	public void close() throws IOException 
	{
	}

	@Override
	public int read(char[] cbuf, int off, int len) throws IOException 
	{
		if (len==0) return 0;
		if (this.len-this.pos=len) return -1;
		return buffer[pos++];
	}

	@Override
	public boolean ready() throws IOException {
		return true;
	}

	@Override
	public void reset() throws IOException {
		pos=mark;
	}

	@Override
	public long skip(long n) throws IOException {
		if (n>len-pos) n=len-pos;
		pos+=n;
		return n;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy