Methods Summary |
---|
public char | charAt(int pos)
try
{
ensure(pos);
return buff.charAt(pos);
}
catch (IOException e)
{
throw new StringIndexOutOfBoundsException(e.getMessage());
}
|
private void | ensure(int idx)Reads chars up to the idx
if (closed)
{
return;
}
if (idx < buff.length())
{
return;
}
read(idx + 1 - buff.length());
|
public boolean | isEnd(int pos)
if (buff.length() > pos)
{
return false;
}
else
{
try
{
ensure(pos);
return (buff.length() <= pos);
}
catch (IOException e)
{
throw new StringIndexOutOfBoundsException(e.getMessage());
}
}
|
private int | read(int n)Reads n characters from the stream and appends them to the buffer
if (closed)
{
return 0;
}
char[] c = new char[n];
int count = 0;
int read = 0;
do
{
read = reader.read(c);
if (read < 0) // EOF
{
closed = true;
break;
}
count += read;
buff.append(c, 0, read);
}
while (count < n);
return count;
|
private void | readAll()Reads rest of the stream.
while(! closed)
{
read(1000);
}
|
public java.lang.String | substring(int offset, int length)
try
{
ensure(offset + length);
return buff.toString().substring(offset, length);
}
catch (IOException e)
{
throw new StringIndexOutOfBoundsException(e.getMessage());
}
|
public java.lang.String | substring(int offset)
try
{
readAll();
return buff.toString().substring(offset);
}
catch (IOException e)
{
throw new StringIndexOutOfBoundsException(e.getMessage());
}
|