tags:

views:

70

answers:

1

I have line in Java and in while I get number:

i = gzipinputstream1.read(abyte0, j, 4096);

From while number:

959
1552
1577
1617
1680

when I want use in php:

$i = fread($handle, 959):

while return:

959,
959,
959,
5

How make that in PHP result will be the same?

A: 

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.

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.

BalusC
rewrited to: `$i = stream_get_contents($handle, 4096, $j);`but it's show 4096.
Mantas
I repeat: *wherein you **omit** the maxlength and offset arguments*. In other words: do *not* specify them. Leave them away. You apparently don't know the content length beforehand. You should also not specify it in Java, unless you're reading in a loop and appending to a byte buffer.
BalusC
I cant change JAVA code. Only in php
Mantas
Omit the maxlength and offset arguments: `$i = stream_get_contents($handle);`.
BalusC
Yes i know what: but i get all bytes. I have rewrite one code to php. And if i get in one line all bits i don't now how remade all in PHP.Java code` i = gzipinputstream1.read(abyte0, j, 4096); if(i != -1) { j += i; if(j + 4096 > k) { byte abyte1[] = new byte[k += 8192]; System.arraycopy(abyte0, 0, abyte1, 0, j); abyte0 = abyte1; } }else{ flag1 = false; }}`
Mantas
JAVA code in while.
Mantas
Update your question. This is hard to understand.
BalusC