@ FFDCIgnore ( { IOException . class , FileNotFoundException . class } ) private static boolean isZip ( File file ) { if ( ! hasZipExtension ( file . getName ( ) ) ) { return false ; } InputStream inputStream = null ; try { inputStream = new FileInputStream ( file ) ; // throws FileNotFoundException ZipInputStream zipInputStream = new ZipInputStream ( inputStream ) ; try { ZipEntry entry = zipInputStream . getNextEntry ( ) ; // throws IOException if ( entry == null ) { Tr . error ( tc , "bad.zip.data" , file . getAbsolutePath ( ) ) ; return false ; } return true ; } catch ( IOException e ) { Tr . error ( tc , "bad.zip.data" , file . getAbsolutePath ( ) ) ; return false ; } } catch ( FileNotFoundException e ) { Tr . error ( tc , "Missing zip file " + file . getAbsolutePath ( ) ) ; return false ; } finally { if ( inputStream != null ) { try { inputStream . close ( ) ; } catch ( IOException e ) { // IGNORE } } } }
Tell if a file is valid to used to create a zip file container .