- 论坛徽章:
- 0
|
回复 1# mineral_cu
你好 , 在么 , 关于这个有个问题想请教,不知道怎么联系到你~
这边测试的时候, 在
if(dataLength%StorageInfo.BYTE_SIZE!=0){
throw new IOException("recv body length: " + data.length + " is not correct");
}
这个部分会抛出异常, BYTE_SIZE 您这边定义的600 得到的是612 !!!
public class StorageInfoCmd extends AbstractCmd<List<StorageInfo>> {
@Override
public Result<List<StorageInfo>> exec(Socket socket) throws IOException {
request(socket.getOutputStream());
Response response = response(socket.getInputStream());
if(response.isSuccess()){
byte[] data = response.getData();
int dataLength = data.length;
if(dataLength%StorageInfo.BYTE_SIZE!=0){
throw new IOException("recv body length: " + data.length + " is not correct");
}
List<StorageInfo> storageInfos = new ArrayList<StorageInfo>();
int offset = 0;
while(offset<dataLength){
StorageInfo storageInfo = new StorageInfo(data,offset);
storageInfos.add(storageInfo);
offset += StorageInfo.BYTE_SIZE;
}
return new Result<List<StorageInfo>>(response.getCode(), storageInfos);
}else{
return new Result<List<StorageInfo>>(response.getCode(), "Error");
}
} |
|