Ejemplo n.º 1
0
 @SuppressWarnings("illegalcatch")
 private void detect(final ResourceIterator iterator) throws IOException {
   InputStream stream;
   while ((stream = iterator.next()) != null) {
     try {
       cpBuffer.readFrom(stream);
       if (hasCafebabe(cpBuffer)) {
         detect(cpBuffer);
       } // else ignore
     } catch (Throwable t) {
       // catch all errors
       if (!(stream instanceof FileInputStream)) {
         // in case of an error we close the ZIP File here
         stream.close();
       }
     } finally {
       // closing InputStream from ZIP Entry is handled by ZipFileIterator
       if (stream instanceof FileInputStream) {
         stream.close();
       }
     }
   }
 }
Ejemplo n.º 2
0
 private boolean hasCafebabe(final ClassFileBuffer buffer) throws IOException {
   return buffer.size() > 4 && buffer.readInt() == 0xCAFEBABE;
 }