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;
}