Here you can find the source of getFileExtension(String file)
private static String getFileExtension(String file)
//package com.java2s; import java.io.*; public class Main { private static String getFileExtension(String file) { String extension = ""; String fileName = new File(file).getName(); int idxOfDot = fileName.lastIndexOf('.'); if (idxOfDot != -1) { extension = fileName.substring(idxOfDot + 1); }// ww w . j av a 2 s . c o m return extension; } }