Java tutorial
//package com.java2s; //License from project: Open Source License import java.io.File; public class Main { public static final String getExtensionWithDot(final File file) { if (file == null) { return ""; } final String name = file.getName(); final int index = name.lastIndexOf("."); if (index == -1) { return ""; } return name.substring(index); } }