Here you can find the source of getFilenameWithoutExtension(File f)
public static String getFilenameWithoutExtension(File f)
//package com.java2s; /*//from ww w. j a v a 2s. co m GanttProject is an opensource project management tool. Copyright (C) 2005-2011 GanttProject team This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import java.io.File; public class Main { private static final char FILE_EXTENSION_SEPARATOR = '.'; /** @return the filename of f without extension */ public static String getFilenameWithoutExtension(File f) { String filename = f.getName(); int i = filename.lastIndexOf(FILE_EXTENSION_SEPARATOR); return i >= 0 ? filename.substring(0, i) : filename; } }