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: BSD License import java.io.File; public class Main { /**/*from w w w . j a v a 2 s . c o m*/ * Utility function to return the lower-cased file extension - the part of * the filename after the last period. * <p> * For example, getFileExtension("myPicture.is.cool.JPEG") would return * "jpeg". * * @param f * The file * @return The file extension in lower case, or null if none exists. */ public static String getFileExtension(File f) { String ext = null; String s = f.getName(); int i = s.lastIndexOf('.'); if (i > 0 && i < s.length() - 1) { ext = s.substring(i + 1).toLowerCase(); } return ext; } }