in velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/VelocityCharStream.java [119:182]
private void FillBuff() throws java.io.IOException
{
if (maxNextCharInd == available)
{
if (available == bufsize)
{
if (tokenBegin > nextBufExpand)
{
bufpos = maxNextCharInd = 0;
available = tokenBegin;
}
else if (tokenBegin < 0)
{
bufpos = maxNextCharInd = 0;
}
else
{
ExpandBuff(false);
}
}
else if (available > tokenBegin)
{
available = bufsize;
}
else if ((tokenBegin - available) < nextBufExpand)
{
ExpandBuff(true);
}
else
{
available = tokenBegin;
}
}
int i;
try
{
if ((i = inputStream.read(buffer, maxNextCharInd,
available - maxNextCharInd)) == -1)
{
if (beforeEOF)
{
inputStream.close();
throw new java.io.IOException();
}
buffer[maxNextCharInd++] = END_OF_FILE;
beforeEOF = true;
}
else
{
maxNextCharInd += i;
}
}
catch(java.io.IOException e)
{
--bufpos;
backup(0);
if (tokenBegin == -1)
{
tokenBegin = bufpos;
}
throw e;
}
}