private static boolean hasZipExtension ( String name ) { int nameLen = name . length ( ) ; // Need '.' plus at least three characters. if ( nameLen < 4 ) { return false ; } // Need '.' plus at least six characters for ".spring". if ( nameLen >= 7 ) { if ( ( name . charAt ( nameLen - 7 ) == ' ' ) && name . regionMatches ( IGNORE_CASE , nameLen - 6 , ZIP_EXTENSION_SPRING , 0 , 6 ) ) { return true ; } } if ( name . charAt ( nameLen - 4 ) != ' ' ) { return false ; } else { for ( String ext : ZIP_EXTENSIONS ) { if ( name . regionMatches ( IGNORE_CASE , nameLen - 3 , ext , 0 , 3 ) ) { // ignore case return true ; } } return false ; } // return name.matches("(?i:(.*)\\.(ZIP|[SEJRW]AR|E[BS]A|SPRING))"); }
Tell if a file name has a zip file type extension .