gpt4 book ai didi

java - 从 FileChannel (Java NIO) 读取 GZIP 文件

转载 作者:塔克拉玛干 更新时间:2023-11-03 04:00:58 28 4
gpt4 key购买 nike

我需要读取/解压给定 FileChannel 的 .gz 文件。

我尝试过使用 GZIPInputStream 提取 GZIP 文件,但这不会占用 FileChannel。我无权访问从中获取 FileChannel 的原始 FileInputStream。

如果有人能告诉我从 FileChannel 读取 GZIP 的好方法(或至少任何方法),我将不胜感激。

改编自 Sun Oracle forums 上的一个问题.

最佳答案

您可以获得一个环绕 FileChannel 的 InputStream:

FileChannel fc = ...
GZIPInputStream gis = new GZIPInputStream(Channels.newInputStream(fc));

Channels在 Java SE 中。

关于java - 从 FileChannel (Java NIO) 读取 GZIP 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3335969/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com