Java examples for java.io:File Extension Name
get File Extension Name from File
//package com.java2s; import java.io.File; import java.util.regex.Pattern; public class Main { public static String getExtension(File file) { String[] segs = file.toString().split(Pattern.quote(".")); return segs[segs.length - 1]; }//from www . j a va2 s. co m public static String getExtension(String filename) { String[] segs = filename.split(Pattern.quote(".")); return segs[segs.length - 1]; } }