[英]Java gzip.read and PHP fread() gives different results
I have line in Java and in while I get number: 我在Java中排队并且在得到编号的同时:
i = gzipinputstream1.read(abyte0, j, 4096);
From while number: 从号码:
959
1552
1577
1617
1680
when I want use in php: 当我想在php中使用时:
$i = fread($handle, 959):
while return: 返回时:
959,
959,
959,
5
How make that in PHP result will be the same? 如何在PHP中使结果相同?
You need to read the stream fully in. Right now you're instructing Java to read a length of max 4096 bytes and you're instructing PHP to read a length of max 959 bytes. 您需要完全读入流。现在,您正在指示Java读取最大4096字节的长度,并指示PHP读取最大959字节的长度。
If the content length is unknown beforehand, then in Java you rather need the InputStream#read()
method which doesn't take any arguments and in PHP the stream_get_contents()
wherein you omit the maxlength and offset arguments. 如果内容长度事先未知,则在Java中,您需要使用
InputStream#read()
方法(该方法不接受任何参数),而在PHP中,需要使用stream_get_contents()
其中省略maxlength和offset参数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.