Here you can find the source of getFileExtension(File file)
public static String getFileExtension(File file)
//package com.java2s; //License from project: Open Source License import java.io.*; public class Main { public static String getFileExtension(File file) { String name = file.getName(); int idx = name.lastIndexOf('.'); if (!file.isDirectory() && idx != -1) { return name.substring(idx + 1, name.length()).toLowerCase(); }/*from w ww.j ava2s .co m*/ return ""; } public static String getName(String path) { int index = path.lastIndexOf(File.separatorChar); if (index < 0) { return path; } return path.substring(index + 1); } }