Here you can find the source of getFileExtension(File f)
private static String getFileExtension(File f)
//package com.java2s; //License from project: Apache License import java.io.File; public class Main { private static String getFileExtension(File f) { String fileName = f.getName(); String fileExtension = fileName; int lastPos = fileName.lastIndexOf('.'); if (lastPos > 0 && lastPos < (fileName.length() - 1)) { fileExtension = fileName.substring(lastPos + 1).toLowerCase(); }/* w w w.j ava 2 s.co m*/ return fileExtension; } public static String getFileExtension(String f) { String fileName = f; String fileExtension = fileName; int lastPos = fileName.lastIndexOf('.'); if (lastPos > 0 && lastPos < (fileName.length() - 1)) { fileExtension = fileName.substring(lastPos + 1).toLowerCase(); } return fileExtension; } }