Here you can find the source of fileExt(String name)
public static String fileExt(String name)
//package com.java2s; /*/*from w ww .ja va 2 s . com*/ * Copyright (C) 2015 University of Oregon * * You may distribute under the terms of either the GNU General Public * License or the Apache License, as specified in the LICENSE file. * * For more information, see the LICENSE file. */ public class Main { /** Return filename extension. */ //---------------------------------------------------------------- public static String fileExt(String name) { String ext = null; String fname = pathName(name); int index = fname.indexOf("."); if (index > 0) ext = fname.substring(index, fname.length()); return ext; } /** Return the last directory or filenname in a path. */ //---------------------------------------------------------------- public static String pathName(String path) { int i = path.lastIndexOf("/"); int j = path.lastIndexOf("\\"); int k = i > j ? i : j; if (k < 0) return path; return path.substring(k + 1, path.length()); } }