否有可能从zipinputstream获得zipentry的输入

否有可能从zipinputstream获得zipentry的输入

本文介绍了是否有可能从zipinputstream获得zipentry的输入流?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从另一个源接收ZipInputStream,我需要将第一个条目的InputStream提供给另一个源。

I'm receiving a ZipInputStream from another source, and I need to provide the first entry's InputStream to another source.

我希望能够这样做没有在设备上保存临时文件,但我知道获取单个条目的InputStream的唯一方法是通过ZipFile.getInputStream(entry),因为我有一个ZipInputStream而不是ZipFile,这是不可能的。

I was hoping to be able to do this without saving a temp file on a device, however the only way I know of getting an InputStream for an individual entry is via ZipFile.getInputStream(entry) and since I have a ZipInputStream and not a ZipFile, that is not possible.

所以我拥有的最佳解决方案是

So the best solution I have is


  1. 将传入的InputStream保存到文件

  2. 读取文件为ZipFile

  3. 使用第一个条目的InputStream

  4. 删除临时文件。

  1. save incoming InputStream to a file
  2. read file as ZipFile
  3. use first entry's InputStream
  4. delete temp file.


推荐答案

想通:

完全有可能,调用ZipInputStream .getNextEntry()将InputStream定位在条目的开头,因此提供ZipInputStream相当于提供ZipEntry的InputStream。

it's entirely possible, the call to ZipInputStream.getNextEntry() positions the InputStream at the start of the entry and therefore supplying the ZipInputStream is the equivalent of supplying a ZipEntry's InputStream.

ZipInputStream是smart e没有处理条目的EOF下游,或者看起来如此。

the ZipInputStream is smart enough to handle the entry's EOF downstream, or so it seems.

p。

这篇关于是否有可能从zipinputstream获得zipentry的输入流?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 09:19