コード例 #1
0
 /**
  * Returns a new InputStream for the given file in the tar archive.
  *
  * @param entry
  * @return an input stream for the given file
  * @throws TarException
  * @throws IOException
  */
 public InputStream getInputStream(TarEntry entry) throws TarException, IOException {
   if (entryStream == null || !entryStream.skipToEntry(entry)) {
     InputStream in = new FileInputStream(file);
     // First, check if it's a GZIPInputStream.
     try {
       in = new GZIPInputStream(in);
     } catch (IOException e) {
       in = new FileInputStream(file);
     }
     entryStream =
         new TarInputStream(in, entry) {
           public void close() {
             // Ignore close() since we want to reuse the stream.
           }
         };
   }
   if (entryStream == null) {
     System.out.println("huh?"); // $NON-NLS-1$
   }
   return entryStream;
 }