char[] buf = new char[len];
int read = 0;
int readTo = 0;
while (read > -1)
{
read = r.read(buf, readTo, 1000);
readTo += read;
}
In above code you are reading the content from 'request.getReader
'and method read
1000 characters into a specifed array buf
, started from readTo
.As the loop increases the minimum requirement of the char size increase as 1000+readTo+........
1st Iteration -> char elements are added from index 0 - 1000
2nd Iteration -> char elements are added from index 1000 - 2000
So if issue arise in 2nd iteration can check that the size of the array must be greater than 2000