从缓存中读数据的问题
BufferedReader br = new BufferedReader(new InputStreamReader(
socket.getInputStream(), "ISO-8859-1"));//读取返回信息
char rt[] = new char[2];
int length = br.read(rt, 0, 2);
按照代码,如果缓存中没有数据,br、rt[]、length分别是什么值?
------解决方案--------------------br就一个读缓冲流;rt[]={0,0}(打印的话,会显示两个框框);length为-1
------解决方案--------------------
InputStream in=socket.getInputStream(),
int bufferSize=in.available();
if(bufferSize==0){
System.out.println("The socket buffer is empty");
}