org.jclarion.clarion.util.SharedReader Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of clarion-runtime Show documentation
Show all versions of clarion-runtime Show documentation
JClarion runtime environment
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