Here you can find the source of getFileExtension(File file)
public static String getFileExtension(File file)
//package com.java2s; //License from project: Apache License import java.io.File; public class Main { public static String getFileExtension(File file) { String filename = file.getName(); int extensionIndex = filename.lastIndexOf("."); String extension;/* w w w.j a va 2s . c om*/ if (extensionIndex == -1) { extension = ""; } else { extension = filename.substring(extensionIndex + 1, filename.length()); } return extension; } }