如何将我们用Java defaltor放气的字符串充气
我正在使用java通过以下函数对字符串进行放气:如何将我们用Java defaltor放气的字符串充气,java,php,android,Java,Php,Android,我正在使用java通过以下函数对字符串进行放气: protected static byte[] Compress(String source) { try { // deficne start time long startTime = System.currentTimeMillis(); //get bytes byte[] bytes = source.getBytes("UTF-8"); De
protected static byte[] Compress(String source) {
try {
// deficne start time
long startTime = System.currentTimeMillis();
//get bytes
byte[] bytes = source.getBytes("UTF-8");
Deflater deflater = new Deflater();
deflater.setInput(bytes);
deflater.finish();
ByteArrayOutputStream bos = new ByteArrayOutputStream(bytes.length);
byte[] buffer = new byte[1024];
while (!deflater.finished()) {
int bytesCompressed = deflater.deflate(buffer);
bos.write(buffer, 0, bytesCompressed);
}
try {
//close the output stream
bos.close();
} catch (IOException ioe) {
System.out.println("Error while closing the stream : " + ioe);
}
//get the compressed byte array from output stream
byte[] compressedArray = bos.toByteArray();
return compressedArray;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
$uncompressed = gzinflate($filepath);
echo $uncompressed;
die();
现在,我想通过以下函数用PHP将该字符串膨胀:
protected static byte[] Compress(String source) {
try {
// deficne start time
long startTime = System.currentTimeMillis();
//get bytes
byte[] bytes = source.getBytes("UTF-8");
Deflater deflater = new Deflater();
deflater.setInput(bytes);
deflater.finish();
ByteArrayOutputStream bos = new ByteArrayOutputStream(bytes.length);
byte[] buffer = new byte[1024];
while (!deflater.finished()) {
int bytesCompressed = deflater.deflate(buffer);
bos.write(buffer, 0, bytesCompressed);
}
try {
//close the output stream
bos.close();
} catch (IOException ioe) {
System.out.println("Error while closing the stream : " + ioe);
}
//get the compressed byte array from output stream
byte[] compressedArray = bos.toByteArray();
return compressedArray;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
$uncompressed = gzinflate($filepath);
echo $uncompressed;
die();
但我在php文件中遇到了数据错误,如何解决这个问题
错误消息是:
警告:gz充气():数据错误
关于您忘记在问题中包含实际的错误消息。谢谢,我已经补充说,此页面上的第一条评论可能与此相关: