首页
学习
活动
专区
圈层
工具
发布
    • 综合排序
    • 最热优先
    • 最新优先
    时间不限
  • 来自专栏传统基础应用开发专栏-不限开发语言

    复杂项目即时通讯从android 5升级android x后遗症之解决报错#79 java.io.EOFException Unexpected end of

    ("Network", "数据流不完整或损坏: " + e.getMessage()); // 可以尝试重新请求数据 retryRequest();}方案2:确保流正确关闭// 确保在使用GZIPInputStream 或InflaterInputStream时正确关闭流GZIPInputStream gzipInputStream = null;try { gzipInputStream = new GZIPInputStream = null) { try { gzipInputStream.close(); } catch (IOException e) { connection.getResponseCode();if (responseCode == HttpURLConnection.HTTP_OK) { // 只有响应正常时才处理数据 try (GZIPInputStream gzip = new GZIPInputStream(connection.getInputStream())) { // 处理压缩数据 Reporter.post(...

    22910编辑于 2025-08-25
  • 来自专栏生活不止眼前的代码

    SpringCloudGateway笔记(7)-响应不全

    gzipInputStream = null; try { gzipInputStream = new GZIPInputStream(new ByteArrayInputStream(content), lenght); StringWriter writer = new StringWriter(); IOUtils.copy(gzipInputStream gzipInputStream = null; try { gzipInputStream = new GZIPInputStream(new ByteArrayInputStream(bytes), length);

    2.7K24发布于 2019-08-30
  • 来自专栏第三方工具

    Gzip压缩文件和压缩字符串,web接口应用

    java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.util.zip.GZIPInputStream gzis = new GZIPInputStream(fis); byte[] buffer = new byte[1024]; int len; gzin = new GZIPInputStream(in); BufferedReader reader = new BufferedReader(new InputStreamReader gzip = new GZIPInputStream(ios); gzip.read(compressed); gzip.close(); String gzipIn = new GZIPInputStream(request.getInputStream()); reader = new BufferedReader(new

    56410编辑于 2024-11-21
  • 来自专栏nginx

    深入解析GZIP解压缩异常:从错误日志到解决方案

    (GZIPInputStream.java:165) at java.util.zip.GZIPInputStream. <init>(GZIPInputStream.java:79) at java.util.zip.GZIPInputStream. <init>(GZIPInputStream.java:91) at cn.ysx.common.util.HttpUtil.decompress(HttpUtil.java:1426) gzipInputStream = new GZIPInputStream(bis); ByteArrayOutputStream bos = new ByteArrayOutputStream ()) { byte[] buffer = new byte[1024]; int len; while ((len = gzipInputStream.read

    20110编辑于 2025-11-15
  • 来自专栏令仔很忙

    令仔代码收藏系列(一)----Java压缩与解压缩

    org.apache.http.util.EntityUtils; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.util.zip.GZIPInputStream ByteArrayOutputStream outStream = new ByteArrayOutputStream(10 * pureResult.length); GZIPInputStream inStream = new GZIPInputStream ( new ByteArrayInputStream(pureResult) );

    73920发布于 2018-09-14
  • 来自专栏强仔仔

    如何高效的处理第三方接口数据?

    ,将json流解析为JsonNode,如下所示: ObjectMapper mapper = new ObjectMapper(); JsonNode root = mapper.readTree((GZIPInputStream 后面发现这样做没起到任何作用,所以只能进行彻底的改造,直接用jackson解析成我们需要的对象,如下所示: private List<ReportAdvertisementDto> parseJsonIO(GZIPInputStream gzipInputStream) { ObjectMapper mapper = new ObjectMapper(); List<ReportAdvertisementDto> advertisementDtoList =new ArrayList<>(); try { advertisementDtoList = mapper.readValue(gzipInputStream, new TypeReference

    1.7K20发布于 2019-07-31
  • 来自专栏全栈程序员必看

    java解析zip文件_java解压zip文件

    = -1) { try { final GZIPInputStream gzipInputStream = new GZIPInputStream(stream); ServletInputStream newStream = new ServletInputStream() { @Override public int read() throws IOException { return gzipInputStream.read

    2K20编辑于 2022-10-04
  • 来自专栏Java学习网

    如何使用Java进行文件压缩和解压缩

    Java提供了ZipInputStream和GZIPInputStream类来完成文件解压缩的任务。 GZIPInputStream类可以用于解压缩GZIP格式的文件,下面是一个演示程序: import java.io.*; import java.util.zip.*; public class UnGZIPExample { public static void main(String[] args) { byte[] buffer = new byte[1024]; try { GZIPInputStream gzipIS = new GZIPInputStream(new FileInputStream("compressed.gz")); String fileName = "output.txt } catch (IOException e) { e.printStackTrace(); } } } 上述代码中,我们首先定义一个名为“compressed.gz”的GZIPInputStream

    1.2K20编辑于 2023-12-15
  • 来自专栏JAVA乐园

    SpringBoot 压缩数据流如何解压

    java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.zip.GZIPInputStream = -1) { GZIPInputStream gzipInputStream = new GZIPInputStream(stream); try { int len = -1; byte[] buffer = new byte[128]; while((len = gzipInputStream.read log.error("uncompress content fail", e); }finally{ try { gzipInputStream.close

    1.7K50发布于 2021-07-22
  • 来自专栏个人教程

    Java中HTTP请求返回乱码 - GZIP压缩问题

    = null)&&(contentEncoding.equals("gzip"))){ is = new GZIPInputStream(conn.getInputStream()); }else java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; import java.util.zip.GZIPInputStream = null)&&(contentEncoding.equals("gzip"))){ is = new GZIPInputStream(conn.getInputStream = null)&&(contentEncoding.equals("gzip"))){ is = new GZIPInputStream(conn.getInputStream

    5.9K41编辑于 2022-06-15
  • 来自专栏java和python

    Java 实现解压 .tar.gz 这种格式的压缩包,递归文件夹,找到tar.gz 格式的压缩包,并且进行解压,解压到这个压缩包所在的文件夹下

    bufferedInputStream = new BufferedInputStream(fileInputStream); GzipCompressorInputStream gzipInputStream bufferedInputStream); TarArchiveInputStream tarInputStream = new TarArchiveInputStream(gzipInputStream

    1.1K10编辑于 2023-12-01
  • 来自专栏让技术和时代并行

    byte数组和String之间的相互转换代码

    public static String converByteToString(byte[] data) { ByteArrayInputStream byteInput = null; GZIPInputStream ] buf = new byte[1024]; try { byteInput = new ByteArrayInputStream(zippedData); gzin = new GZIPInputStream

    80120发布于 2019-04-16
  • 来自专栏Albert陈凯

    2018-06-13 RestTemplate处理Gzip压缩

    isNull(compressed) || compressed.length == 0) { return null; } try (final GZIPInputStream gzipInput = new GZIPInputStream(new ByteArrayInputStream(compressed)); final StringWriter

    1.6K30发布于 2018-06-19
  • 来自专栏Ray学习笔记

    Ajax 与 Gzip 交互

    java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.zip.GZIPInputStream ByteArrayInputStream in; in = new ByteArrayInputStream(b); // 使用默认缓冲区大小创建新的输入流 GZIPInputStream gzip = new GZIPInputStream(in); byte[] buffer = new byte[256]; int n = 0;

    1.9K10发布于 2020-08-03
  • 来自专栏全栈程序员必看

    web性能优化–用gzip压缩资源文件

    java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.zip.GZIPInputStream ByteArrayOutputStream(); ByteArrayInputStream in = new ByteArrayInputStream(bytes); try { GZIPInputStream ungzip = new GZIPInputStream(in); byte[] buffer = new byte[256]; int n; ); ByteArrayInputStream in = new ByteArrayInputStream(bytes); try { GZIPInputStream ungzip = new GZIPInputStream(in); byte[] buffer = new byte[256]; int n;

    88310编辑于 2022-07-02
  • 来自专栏Android开发指南

    5.post上传和压缩、插件模拟请求

    header.getValue())) { isUseGzip = true; } } //3.根据是否使用gzip.解压具体的数据 if (isUseGzip) { GZIPInputStream in = new GZIPInputStream(entity.getContent()); result = IoUtils.convertStreamToString(in); } else response.getEntity(); //3.根据是否使用gzip.解压具体的数据 String result = ""; if (isUseGzip) { GZIPInputStream in = new GZIPInputStream(entity.getContent()); result = IoUtils.convertStreamToString(in);

    2.4K90发布于 2018-05-14
  • 来自专栏码字搬砖

    字符串的压缩以及解压缩

    bytes) throws Exception { if (bytes == null || bytes.length == 0) { return bytes.toString(); } GZIPInputStream gis = new GZIPInputStream(new ByteArrayInputStream(bytes)); BufferedReader bf = new BufferedReader

    1.5K10发布于 2020-06-30
  • 来自专栏Java日常

    URLEncode和URLDecode的注意事项

    java.io.UnsupportedEncodingException; import java.net.URLDecoder; import java.net.URLEncoder; import java.util.zip.GZIPInputStream ByteArrayInputStream(str .getBytes("ISO-8859-1")); // 使用默认缓冲区大小创建新的输入流 GZIPInputStream gzip = new GZIPInputStream(in); byte[] buffer = new byte[256]; int n = 0; while

    3.1K20发布于 2020-12-25
  • 来自专栏第三方工具

    Illegal character ((CTRL-CHAR, code 31))问题排查 gzip接口返回 RestTemplate GET POST请求

    java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; import java.util.zip.GZIPInputStream resContent = null; HttpURLConnection conn = null; GZIPOutputStream out = null; GZIPInputStream int resCode = conn.getResponseCode(); if(resCode == 200){ in = new GZIPInputStream

    42010编辑于 2024-10-09
  • Gzip 详解:压缩算法的原理与应用

    shutil.copyfileobj(f_in, f_out)4.2 在 Java 中使用 Gzip在 Java 中,可以使用 java.util.zip.GZIPOutputStream 和 GZIPInputStream *;import java.util.zip.GZIPOutputStream;import java.util.zip.GZIPInputStream;public class GzipExample gzipFile, String newFile) { try (FileInputStream fis = new FileInputStream(gzipFile); GZIPInputStream gis = new GZIPInputStream(fis); FileOutputStream fos = new FileOutputStream(newFile)) {

    2K00编辑于 2024-09-07
领券