Here you can find the source of getPathExtension(final String path)
Parameter | Description |
---|---|
path | path to parse |
public static String getPathExtension(final String path)
import java.io.File; import java.io.IOException; import org.apache.log4j.Logger; public class Main{ /**/*from w w w . j a v a 2 s . c o m*/ * Returns extension of path without ".". For example, png, jpg etc. * * @param path * path to parse * @return path extension or null if no extension in given path */ public static String getPathExtension(final String path) { String result = null; if (path != null) { result = ""; if (path.lastIndexOf('.') != -1) { result = path.substring(path.lastIndexOf('.')); if (result.startsWith(".")) { result = result.substring(1); } } } return result; } }