24 lines
660 B
Java
24 lines
660 B
Java
![]() |
package com.yjdsj.common.utils;
|
||
|
|
||
|
import java.io.IOException;
|
||
|
import java.nio.charset.StandardCharsets;
|
||
|
|
||
|
public class DecompressionUtil {
|
||
|
|
||
|
/**
|
||
|
* 将压缩数据解压并转换为字符串
|
||
|
*
|
||
|
* @param compressedData
|
||
|
* @return
|
||
|
*/
|
||
|
public static String decompressAndConvertToString(byte[] compressedData) {
|
||
|
try {
|
||
|
byte[] decompressedData = GzipDecompressorUtil.decompress(compressedData);
|
||
|
return new String(decompressedData, StandardCharsets.UTF_8);
|
||
|
} catch (IOException e) {
|
||
|
e.printStackTrace();
|
||
|
return "Failed to decompress data: " + e.getMessage();
|
||
|
}
|
||
|
}
|
||
|
}
|