顺便一提,很诡异的是,我把 bytesRes = new byte[4024]; 改成 bytesRes = new byte[14024];(网络文本的子节数小于14024) 就一直都正确咯。
is=url.openStream(); bytesRes = new byte[4024]; // Data = new byte[0]; ByteArrayOutputStream output = new ByteArrayOutputStream(); while ((tmp = is.read(bytesRes)) != -1) {//这个hebing函数的功能是把 bytesRes数组的 tmp个字节加入到data中去 //Data = hebing(Data, bytesRes, tmp); output.write(bytesRes, 0, tmp); } is.close();byte[] result = output.toByteArray(); // Here is your expected file data
改成 bytesRes = new byte[14024];(网络文本的子节数小于14024)
就一直都正确咯。
bytesRes = new byte[4024];
// Data = new byte[0];
ByteArrayOutputStream output = new ByteArrayOutputStream();
while ((tmp = is.read(bytesRes)) != -1) {//这个hebing函数的功能是把 bytesRes数组的 tmp个字节加入到data中去
//Data = hebing(Data, bytesRes, tmp);
output.write(bytesRes, 0, tmp);
}
is.close();byte[] result = output.toByteArray(); // Here is your expected file data