code: public static String getFileExtension(File file) {
          if (file == null) {
              return null;
          }
  
          String fileName = file.getName();
          int dotPos = fileName.lastIndexOf('.');
          return dotPos == -1 ? null : fileName.substring(dotPos + 1);
      }
docs: Given a File object, return the extension (portion after the final '.'), if any.
  If no extension, returns null.  If the file parameter is null, returns null.
  Does not check if the file actually exists or not.