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;
}
int c;
int i = n;
while (--i >= 0)
{
c = is.read();
if (c < 0) // EOF
{
closed = true;
break;
}
buff.append((char) c);
}
return n - i;
|
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());
}
|