Here you can find the source of getFileExtension(File f)
Parameter | Description |
---|---|
f | the file |
public static String getFileExtension(File f)
//package com.java2s; //License from project: Open Source License import java.io.File; public class Main { /**/*w w w.j a v a 2 s . c om*/ * @param f * the file * @return the extension of f */ public static String getFileExtension(File f) { if (f.isFile()) { String name = f.getName(); int pos = name.lastIndexOf("."); if (pos != -1) { return name.substring(pos + 1, name.length()); } } return ""; } }