Here you can find the source of getFileExtension(File file)
Parameter | Description |
---|---|
file | a parameter |
public static String getFileExtension(File file)
//package com.java2s; //License from project: Open Source License import java.io.*; public class Main { private static final String DOT = "."; /**/*from w w w .java 2 s. co m*/ * returns the file extension, or empty-string of the file has no extension. * @param file * @return */ public static String getFileExtension(File file) { String filePath = file.getPath(); int index = filePath.lastIndexOf(DOT); if (index >= 0) return filePath.substring(index + 1); else return ""; } }