• Post Reply Bookmark Topic Watch Topic
  • New Topic

ServletInputStream class error  RSS feed

 
MONZY THARIAN
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,
if i am trying to read readLine method of ServletInputStream twice . It is throwing IOException.
What might be cause of the error. I am using jsp request object i.e request.getInputStream to get ServletInputStream class.

public int readLine(byte[] b, int off, int len) throws IOException;
Thanks
Monzy
 
MONZY THARIAN
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The method public int readLine(byte[] b, int off, int len) throws IOException;
is returning -1 when i am trying to read it for the secomd time. First time it is giving returning proper value.

Kindly suggest .
Thanks in advance.
 
Michael Fitzmaurice
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
When it returns -1, this means there is no more data to read, as with all io streams. You need to construct your read loop with this as the terminating condition, so that you don't try to read from it when there is no more data available.
Michael
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!