D
dutone
I get the above exception ('String index out of range: -5') at random
points during readMultiLine()'s network read (listed below). According
to doc. the only method that could be throwing this is sb.delete() but
it doesnt meet the conditions for the exception. When I run it on a
file, no error, only when doing network io.
Any Ideas?????
main()
{
//Init......
String lines[] = readMultiLine();
// ....
}
private String readLine() throws IOException
{
int c;
sb.delete(0,sb.length());
c = is.read();
while( c > 0 ) {
sb.append((char)c);
if( (char)c == '\n' ) break;
c = is.read();
}
return ( (sb.length() > 0) ? sb.toString():null);
}
private String[] readMultiLine() throws IOException
{
String retval[] = null;
String x = readLine();
lineBuffer.removeAllElements();
while(x != null) {
if( x.equals("^\r\n") ) break;
lineBuffer.addElement(x);
x = readLine();
}
retval = new String[lineBuffer.size()];
lineBuffer.copyInto(retval);
return (retval);
}
points during readMultiLine()'s network read (listed below). According
to doc. the only method that could be throwing this is sb.delete() but
it doesnt meet the conditions for the exception. When I run it on a
file, no error, only when doing network io.
Any Ideas?????
main()
{
//Init......
String lines[] = readMultiLine();
// ....
}
private String readLine() throws IOException
{
int c;
sb.delete(0,sb.length());
c = is.read();
while( c > 0 ) {
sb.append((char)c);
if( (char)c == '\n' ) break;
c = is.read();
}
return ( (sb.length() > 0) ? sb.toString():null);
}
private String[] readMultiLine() throws IOException
{
String retval[] = null;
String x = readLine();
lineBuffer.removeAllElements();
while(x != null) {
if( x.equals("^\r\n") ) break;
lineBuffer.addElement(x);
x = readLine();
}
retval = new String[lineBuffer.size()];
lineBuffer.copyInto(retval);
return (retval);
}