As Title.
Here is code:
InputStream is = tcp.getInputStream();
int bytesRead = 0;
do{
byte[] byteIn = new byte[16* 1024];
bytesRead = is.read(byteIn, 0, 16*1024);
pStore.storeData(b开发者_C百科yteIn, 1024);
processMessage(pStore.readAll());
pStore.clear();
}while(bytesRead>0);
Problem I have is that it never reaches the end of the while loop. Any suggestions would be muchly appreciated.
Thanks :)
The Javadoc to InputStream.read()
says:
This method blocks until input data is available
Which is what you may be seeing.
You may test with InputStream.available()
if there is any data to be read first.
精彩评论