当前位置:网站首页>Source code analysis of GZIPOutputStream class
Source code analysis of GZIPOutputStream class
2022-08-01 18:55:00 【51CTO】
这是 《水煮 JDK 源码》系列 的第5篇文章,计划撰写100篇关于JDK源码相关的文章
GZIPOutputStream 类位于 java.util.zip 包下,继承于 DeflaterOutputStream 类,它实现了一个流式过滤器,主要用于以GZIPfile format to write compressed data,其UML类图如下:

类声明如下:
1、成员变量
GZIPOutputStream 定义了1个成员变量,如下:
CRC32 Is a computational data flow CRC-32 Checksum class,Mainly used to verify the integrity of compressed data.
2、构造函数
创建 GZIPOutputStream The compressed output streams are mainly4种方式,如下:
GZIPOutputStream The class is mainly used for writingGZIPoutput stream of compressed data,Hence the need for a compressor Deflater.
3、写入数据方法
GZIPOutputStream The class provides a method to write data,其定义如下:
在创建 GZIPOutputStream When compressing the output stream,会使用 writeHeader() 方法写入GZIPmember header,So what header information will be written??You can look at the definition of this method:
从代码实现可以看出,will write in total10个字节的头信息,Include header information magic number、Compression method and various flags, etc.,These header information also need to be checked one by one when decompressing.
Have write head information method,There will naturally be a way to write tail information,about writing tail information writeTrailer() 方法定义如下:
上面调用的 writeInt() 方法定义如下:
4、其他方法
When all compressed data is written to the output stream,This time you can call to complete finish() 方法,如下:
5、测试应用
GZIPOutputStream Classes can be used to compress data,Then a sample code for compressing a string is given below:
运行程序后,Since it is a compressed string,So the output print is garbled.
边栏推荐
- Live chat system technology (8) : vivo live IM message module architecture practice in the system
- opencv syntax Mat type summary
- Keras deep learning practice - traffic sign recognition
- When compiling a program with boost library with VS2013, it prompts fatal error C1001: An internal error occurred in the compiler
- AntDB database appeared in the 24th high-speed exhibition, helping smart high-speed innovative applications
- Flowable-based upp (unified process platform) running performance optimization
- 突破性能天花板!亚信数据库支撑 10 多亿用户,峰值每秒百万交易
- 2022,程序员应该如何找工作
- TestNG多个xml进行自动化测试
- 深入浅出Flask PIN
猜你喜欢

C#/VB.NET:从 PDF 文档中提取所有表格

log factory (detail)

B005 - STC8 based single chip microcomputer intelligent street light control system

Keras deep learning practice - traffic sign recognition

DAO开发教程【WEB3.0】

C#/VB.NET: extracted from the PDF document all form

483-82(23、239、450、113)

Golang协程调度器scheduler怎么使用

Zabbix6.0钉钉机器人告警

在全志V853开发板试编译QT测试
随机推荐
Leetcode74. Search 2D Matrix
Shell script topic (07): file from cfs to bos
JVM运行时数据区与JMM内存模型是什么
在全志V853开发板试编译QT测试
力扣刷题之移动零
塔防海岸线用户协议
C#/VB.NET:从 PDF 文档中提取所有表格
7月30号|来一场手把手助您打造智能视觉新爆款的技术动手实验
123123123123
odoo 编码规范(编程规范、编码指南)
30分钟成为Contributor|如何多方位参与OpenHarmony开源贡献?
Live chat system technology (8) : vivo live IM message module architecture practice in the system
【全民编程】《软件编程-讲课视频》【零基础入门到实战应用】
选择合适的 DevOps 工具,从理解 DevOps 开始
B005 - STC8 based single chip microcomputer intelligent street light control system
网站建设流程
Multi-Party Threshold Private Set Intersection with Sublinear Communication-2021: Interpretation
行业沙龙第二期丨如何通过供应链数字化业务协同,赋能化工企业降本增效?
【木棉花】#夏日挑战赛# 鸿蒙小游戏项目——数独Sudoku(3)
Prometheus的Recording rules实践