Here you can find the source of getFileExtension(String filename)
public static String getFileExtension(String filename)
//package com.java2s; //License from project: Apache License import java.io.*; public class Main { /**/*from w ww . j a va 2 s .c o m*/ * exclude "." */ public static String getFileExtension(String filename) { try { return filename.substring(filename.lastIndexOf(".") + 1); } catch (Exception e) { return null; } } /** * exclude "." */ public static String getFileExtension(File file) { return getFileExtension(file.getAbsolutePath()); } }