- 論壇徽章:
- 0
|
回復(fù) 1# mineral_cu
你好 , 在么 , 關(guān)于這個(gè)有個(gè)問題想請(qǐng)教,不知道怎么聯(lián)系到你~
這邊測(cè)試的時(shí)候, 在
if(dataLength%StorageInfo.BYTE_SIZE!=0){
throw new IOException("recv body length: " + data.length + " is not correct");
}
這個(gè)部分會(huì)拋出異常, 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");
}
} |
|