Here you can find the source of getFileExtension(File file)
Parameter | Description |
---|---|
file | The file to get the file extension |
static String getFileExtension(File file)
//package com.java2s; //License from project: Open Source License import java.io.File; public class Main { /**//from ww w. j a va 2 s . com * Gets the file extension from a file * * @param file * The file to get the file extension * @return The file extension */ // visible for testing static String getFileExtension(File file) { if (file == null) { return null; } if (!file.getName().contains(".")) { return null; } return file.getName().substring(file.getName().lastIndexOf('.') + 1); } }