Here you can find the source of fileExtension(String filename)
Parameter | Description |
---|---|
filename | The name of the file whose extension we want |
public static String fileExtension(String filename)
//package com.java2s; //License from project: Open Source License public class Main { /*********************************************************** * @param filename/*from w ww . j a va 2 s .c om*/ * The name of the file whose extension we want ***********************************************************/ public static String fileExtension(String filename) { String extension = ""; int i = filename.lastIndexOf('.'); int p = Math.max(filename.lastIndexOf('/'), filename.lastIndexOf('\\')); if (i > p) { extension = filename.substring(i + 1); } return extension; } }