code: public static boolean isValidFileExtension(String filename, String allowedFileExtensions, String deniedFileExtensions) {
          if (filename == null) {
              return false;
          }
  
          String ext = getExtension(filename).toLowerCase();
  
          if (allowedFileExtensions != null && !allowedFileExtensions.isEmpty()) {
              if (ext.length() == 0) {
                  return false;
              }
  
              StringTokenizer st = new StringTokenizer(allowedFileExtensions.toLowerCase(), EXTENSIONS_SEPARATORS);
              while (st.hasMoreTokens()) {
                  String ext2 = st.nextToken();
                  if (ext.equals(ext2)) {
                      return true;
                  }
              }
  
              return false;
          }
  
          if (deniedFileExtensions != null && !deniedFileExtensions.isEmpty()) {
              if (ext.length() == 0) {
                  return true;
              }
  
              StringTokenizer st = new StringTokenizer(deniedFileExtensions.toLowerCase(), EXTENSIONS_SEPARATORS);
              while (st.hasMoreTokens()) {
                  String ext2 = st.nextToken();
                  if (ext.equals(ext2)) {
                      return false;
                  }
              }
  
              return true;
          }
  
          return true;
      }
docs: Checks whether the extension of the filename is valid.
  The extension check is case-sensitive on all platforms.
  
  @param filename the filename to query, null returns false
  @param allowedFileExtensions the allowed file extensions
  @param deniedFileExtensions the denied file extensions
  @return true if is valid file extension; false otherwise