Here you can find the source of getExtension(File f)
Method to get the extension of the file, in lowercase.
public static String getExtension(File f)
//package com.java2s; import java.io.File; import javax.swing.JFileChooser; public class Main { /**/*ww w . j a va 2s .co m*/ * <p> * Method to get the extension of the file, in lowercase. * </p> * * @return the extension string */ public static String getExtension(File f) { String s = f.getName(); int i = s.lastIndexOf('.'); if (i > 0 && i < s.length() - 1) return s.substring(i + 1).toLowerCase(); return ""; } /** * <p> * Method to get the extension of the file filter, in lowercase * </p> * * @return the extension string */ public static String getExtension(JFileChooser f) { String description = f.getFileFilter().getDescription(); int extensionStart = description.lastIndexOf("."); String extension = description.substring(extensionStart + 1, description.length() - 1); return extension; } }