InputStream missing CR
Hellow
I'm using InputStream
for(;;){
try{
int cbToRead = input.available()
if (cbToRead<1) cbToRead=20;
byte b[];
b = new byte[cbToRead];
input.read(b);
System.out.println( new String(b) );
}
}catch (Exception e) {
System.out.printlnt(e.getMessage());
e.printStackTrace();
}
its work fine but after fiew loops it got an Exception
missing CR
what is CR
[466 byte] By [
Ori-Gila] at [2007-11-27 7:30:46]

BTW most of this code is (a) incorrect usage of available(); (b) incorrect use of read(); (c) a waste of computation time; and (d) a waste of memory and GC.
Try this:
byte[] buffer = new byte[8192];
int count;
while ((count = input.read(buffer)) > 0)
{
String s = new String(buffer, 0, count);
System.out.println(s);
}
plus your exception handling.
ejpa at 2007-7-12 19:11:01 >

Hi its make it wores
sun.net.www.http.ChunkedInputStream.processRaw(ChunkedInputStream.java:378)
sun.net.www.http.ChunkedInputStream.readAheadBlocking(ChunkedInputStream.java:545)
sun.net.www.http.ChunkedInputStream.readAhead(ChunkedInputStream.java:582)
sun.net.www.http.ChunkedInputStream.read(ChunkedInputStream.java:669)
java.io.FilterInputStream.read(FilterInputStream.java:116)
sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.read(HttpURLConnection.java:2364)
sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.read(HttpURLConnection.java:2359)
test.client.TestClient.receiveMesages(TestClient.java:251)
test.client.TestClient.access$2(TestClient.java:224)
test.client.TestClient$3.run(TestClient.java:135)