title: Read all files in a directory from inside Google App Engine app
body: <p>I understand that Google App Engine (GAE) allows you to read any file inside the exploded WAR using several methods like:</p>
  
  <pre><code>String file = "/WEB-INF/name-of-my-filexml";
  InputStream in = getClass().getResourceAsStream(file);
  </code></pre>
  
  <p>The problem is, I need to deploy my web app with a directory structure like this:</p>
  
  <pre><code>MyApp/
      WEB-INF/
          lib/
          classes/
          web.xml
          appengine-web.xml
          ...
  
          profiles/
              fizz.txt
              buzz.txt
              foo.txt
              ... dozens of other text files
  </code></pre>
  
  <p>I need a way to read each <code>profiles/*.txt</code> file into a Java string. And before anyone comments <strong>well why not just hardcode the strings, dude...</strong>, let's just say that I'm cutting out a lot of backstory here for the sake of posting a simple question. Humor me, and let's pretend I cannot hardcode the strings. Normally, if I had full access to <code>java.io.*</code>, I'd just do something like:</p>
  
  <pre><code>File profilesHome = new File("path/to/profiles");
  File[] profiles = profilesHome.listFiles();
  List&lt;String&gt; profileList = new ArrayList&lt;String&gt;();
  for(File profile : profiles)
      profileList.add(readFileIntoString(profile));
  </code></pre>
  
  <p>But here, I don't think I can invoke <code>File#listFiles()</code>, and if all I have is the <code>InputStream</code> that I get back from <code>getClass().getResourceAsStream(file)</code>, I'm not sure how to turn that into a <code>File</code> handle or String object. Any ideas? Thanks in advance.</p>
  
  <p><strong>Update:</strong> using <code>ZipInputStream</code> suggestion:</p>
  
  <pre><code>InputStream inputStream = event.getServletContext()
          .getResourceAsStream("/WEB-INF/profiles.zip");
  ZipInputStream zipInputStream = new ZipInputStream(inputStream);
  List&lt;String&gt; list = new ArrayList&lt;String&gt;();
  ZipEntry currEntry;
  try {
      while((currEntry = zipInputStream.getNextEntry()) != null)
          // TODO: How to convert the contents of currEntry to a string
          // in a manner that is GAE-friendly?
          list.add(convertEntryContentsToString(currEntry));
  } catch (IOException e) {
      e.printStackTrace();
  }
  </code></pre>
  
  <p>Now, <strong>how do I implement <code>convertEntryContentsToString(ZipEntry)</code>?</strong></p>