可以使用循环,并判断是否已经读取35个字节,如果你是使用协议接收且不定长度的话,则要自己编写接收过程。
下面的android代码没有经过验证,仅供参考
ByteArrayBuffer buffer;//最终读取到的数据缓冲区
int readCount = 0; // 已经成功读取的字节的个数
while (readCount < 35) {
if (isTimeOut()){return;}//接收超时,这部分代码省略,如果不需要,则这行就不要了。
byte[] btemp;//每次读取用临时缓冲区
int iCount = read(fd,btemp, 35 - readCount);
readCount +=iCount ;
buffer.append(btemp, 0,iCount );
}
byte[] bresult=buffer.toByteArray();