使用java和google app engine解压sp上载的zip文件中的特定文件

使用java和google app engine解压sp上载的zip文件中的特定文件,java,jsp,google-app-engine,servlets,Java,Jsp,Google App Engine,Servlets,我一直在试图找到使用java和Google app engine解压特定文件的解决方案。我尝试过使用ZipInputStream,但无法访问jsp中上载的zip文件。有人能帮我摆脱困境吗 ServletFileUpload upload = new ServletFileUpload(); resp.setContentType("text/plain"); FileItemIterator iterator = upload.getItemI

我一直在试图找到使用java和Google app engine解压特定文件的解决方案。我尝试过使用ZipInputStream,但无法访问jsp中上载的zip文件。有人能帮我摆脱困境吗

ServletFileUpload upload = new ServletFileUpload();
             resp.setContentType("text/plain");
             FileItemIterator iterator = upload.getItemIterator(req);
              while (iterator.hasNext()) {
                  FileItemStream fileItemStream = iterator.next();
                  InputStream InputStream = fileItemStream.openStream();
                  if (!fileItemStream.isFormField()) {
                      ZipInputStream zis = new ZipInputStream(new BufferedInputStream(InputStream));
                      ZipEntry entry;
                      while ((entry = zis.getNextEntry()) != null) {

                          //code to access required file in the zip file
                      }

                  } 
              }

我猜
ZipInputStream
需要可查找的流。servlet(以及一般的网络)返回的流是不可查找的

尝试读取整个流,然后用
ByteArrayInputStream将其包装成

byte[] bytes = readBytes(fileItemStream.openStream());
InputStream bufferedStream = new ByteArrayInputStream(bytes);

public static byte[] readBytes(InputStream is) throws IOException {
  ByteArrayOutputStream buffer = new ByteArrayOutputStream();

  int len;
  byte[] data = new byte[100000];
  while ((len = is.read(data, 0, data.length)) != -1) {
    buffer.write(data, 0, len);
  }

  buffer.flush();
  return buffer.toByteArray();
}

谢谢你的回复,彼得。请参考上面的内容,我已经编辑了代码。我是java新手。你能告诉我读取zip文件的过程吗?