code: public static String getFileExtension(final String fileName) {
          if (fileName == null) return null;
  
          final int lastPeriodIndex = fileName.lastIndexOf(".");
          // make sure there is an extension, and that the filename doesn't end with a period
          if (lastPeriodIndex != -1 && lastPeriodIndex < fileName.length() - 1) {
              final String extension = fileName.substring(lastPeriodIndex + 1);
              return extension;
          }
  
          return null;
      }
docs: Gets the extension for a file.
  
  @param fileName The name of the file. eg Image.jpg
  @return The filename extension for the file if it has one, otherwise null.