Here you can find the source of getFileName(File file)
public static String getFileName(File file)
//package com.java2s; //License from project: Apache License import java.io.File; public class Main { public static String getFileName(File file) { String[] nameArr = file.getName().split("\\."); StringBuilder name = new StringBuilder(); for (int i = 0; i < nameArr.length - 1; i++) { name.append(nameArr[i]);/*from w w w . j av a 2 s. com*/ if (i != nameArr.length - 2) { name.append("."); } } return name.toString(); } }