- require 'zlib'
- file = 'compressed.gz'
- Zlib::GzipWriter.open(file) do |gzip|
- gzip << "this is a test."
- gzip.close
- end
- open(file, 'rb') { |f| f.read(10) }
- Zlib::GzipReader.open(file) { |gzip| puts gzip.read }
- #该片段来自于http://www.codesnippet.cn/detail/190220132128.html
来源: http://www.codesnippet.cn/detail/190220132128.html