Here you can find the source of getFileExtension(File file)
Parameter | Description |
---|---|
file | A given file. |
public static String getFileExtension(File file)
//package com.java2s; //License from project: Open Source License import java.io.File; public class Main { /**/* ww w.j a v a 2 s . c o m*/ * Get the file extension of given file. * * @param file A given file. * @return String the file extension if any, otherwise null. */ public static String getFileExtension(File file) { String fileName = file.getName(); int position = fileName.lastIndexOf('.'); if (position == -1) return null; return fileName.substring(position + 1); } }