当前位置: 首页 > news >正文

文件流,gzip解压,压缩

目录 文件画布 写入 (空文件

Fout=new File(Parent,entry.getName());)

FileOutputStream out=new FileOutputStream(Fout);

BufferedOutputStream Bout=new BufferedOutputStream(out);

其他流量基于基础包装文件--文件流---字节流 顺序

pbf一般是形成后再压缩

目录:

(new File(Fout.getParent())).mkdirs(); 建好目录

流:

File Fout=new File(Parent,entry.getName());) 建好空白画布--具体文件名

FileOutputStream fileOutputStream = new FileOutputStream("C:\\Desktop\\consiste.xlsx");

FileOutputStream out=new FileOutputStream(Fout);

BufferedOutputStream Bout=new BufferedOutputStream(out); 字符流

或ByteArrayOutputStream o = new ByteArrayOutputStream(1024) 字节流

Bout.toByteArray()

其他流量基于基础包装文件--文件流---字节流 顺序

需要读写的流经过 GZIPInputStream GZIPOutputStream 对应构造函数包装就有了对应加压解压功能

File file = new File("C:\\Users\\h.yu\\Downloads\\pbf\\pbf\\1669358890231_1669358895639.z.pbf");

File fileo = new File("C:\\Users\\h3.yu\\Downloads\\pbf\\pbf");

byte[] output = null;

FileInputStream fis = new FileInputStream(file);

File Fout =new File(fileo,"3313.pbf");

FileOutputStream out=new FileOutputStream(Fout);

GzipUtils.decompress(fis,out);

import java.io.InputStream;

import java.io.OutputStream;

import java.util.zip.GZIPInputStream;

import java.util.zip.GZIPOutputStream;

public class GzipUtils {

/**

* 数据解压缩

*

* @param is

* @param os

* @throws Exception

*/

public static void decompress(InputStream is, OutputStream os)

throws Exception {

GZIPInputStream gis = new GZIPInputStream(is);

int count;

byte data[] = new byte[1024];

while ((count = gis.read(data, 0, 1024)) != -1) {

os.write(data, 0, count);

}

gis.close();

}

/**

* 数据压缩

*

* @param is

* @param os

* @throws Exception

*/

public static void compress(InputStream is, OutputStream os)

throws Exception {

GZIPOutputStream gos = new GZIPOutputStream(os);

int count;

byte data[] = new byte[1024];

while ((count = is.read(data, 0, 1024)) != -1) {

gos.write(data, 0, count);

}

gos.finish();

gos.flush();

gos.close();

}

}

http://www.lryc.cn/news/9156.html

相关文章:

  • 在线开会,来开开圆桌会议吧~
  • 使用营销自动化的 7 大主要优势
  • 【图像分类】基于PyTorch搭建GRU实现MNIST手写数字体识别(单/双向GRU,附完整代码和数据集)
  • day14_oop_抽象_接口
  • 模式识别 | MATLAB实现DNN深度神经网络模式分类识别
  • 【C++】类和对象三大特性--继承
  • MySQL的存储引擎
  • 工程项目管理系统源码-简洁+好用+全面-工程项目管理系统
  • 什么是STAR原则?
  • 前置知识-初值问题、显式隐式龙格库塔方法、Butcher阵列
  • PythonWeb Django PostgreSQL创建Web项目(二)
  • Python学习笔记:使用字符串
  • echarts饼图封装
  • Web3.0 教学基础一
  • body使用渐变色无效的原因之一:html没有设置高度
  • Python3 函数实例及演示
  • HTB打靶(Active Directory 101 Multimaster)
  • 漏洞预警|Apache Sling JCR Base 存在JNDI注入漏洞
  • 【学习笔记】DFA的构造
  • MyBatis 之二(增、删、改操作)
  • 28k入职腾讯测试岗那天,我哭了,这5个月付出的一切总算没有白费~
  • 【surfaceflinger源码分析】surfaceflinger进程的消息驱动模型
  • 「架构师」001计算机组成与体系结构
  • 既然有HTTP协议,为什么还要有RPC
  • 【新2023】华为OD机试 - 选座位(Python)
  • 数据分析与SAS学习笔记4
  • Xepor:一款针对逆向工程和安全分析的Web路由框架
  • Hadoop核心组成和生态系统简介
  • Flutter-Charts_painter大数据量绘制性能优化-数据收敛
  • 使用 GeForce Experience 更新 NVIDIA GPU 显卡驱动