1、使用 tcp 协议 读取 输入流的固定长度的字节数
public static byte[] getTcpSpecificBytes(BufferedInputStream bis,int length) throws IOException{
byte[] bytes = new byte[len];
int readLength = 0;
int hasReadedLength = 0;
while((readLength = bis.read(bytes, hasReadedLength, length - hasReadedLength)) > 0 ){
hasReadedLength += readLength;
}
return bytes;
}
原文:http://www.cnblogs.com/shlerlock/p/7766148.html