我有一个类似如下的方法:
public void put(@Nonnull final InputStream inputStream, @Nonnull final String uniqueId) throws PersistenceException {
// a.) create gzip of inputStream
final GZIPInputStream zipInputStream;
try {
zipInputStream = new GZIPInputStream(inputStream);
} catch (IOException e) {
e.printStackTrace();
throw new PersistenceException("Persistence Service could not received input stream to persist for " + uniqueId);
}
我想把inputStream
转换成zipInputStream
,有什么方法可以做到吗?
- 上述方法是不正确的,会抛出异常,提示“不是Zip格式”
对我来说,将Java流进行转换确实很困惑,我经常无法正确处理它们
InputStream
返回 GZIP 内容?异常信息明确说明它不是。具体的功能要求是什么?为什么你需要以这种方式“转换”它? - BalusCAmazon S3
上,以节省空间和减少费用,因此输入流是我正在尝试压缩并发送到S3
的文档。 - daydreamer