Here you can find the source of GetFileNameWithoutExt(String file_path)
Parameter | Description |
---|---|
file_path | a parameter |
public static String GetFileNameWithoutExt(String file_path)
//package com.java2s; /*Copyright 2008 by Vladimir Polony, Stupy 24, Banska Bystrica, Slovakia /*from w w w. j a v a2s . c om*/ This file is part of OpenRep FREE homeopathic software. OpenRep FREE 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. OpenRep FREE 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 OpenRep FREE. If not, see <http://www.gnu.org/licenses/>.*/ public class Main { /** standard extension of any file == '.' */ public static final String FILE_EXTENSION_SEPARATOR = "."; /** Returns the name of the file without the extension * * @param file_path * @return */ public static String GetFileNameWithoutExt(String file_path) { int pos = file_path.lastIndexOf(FILE_EXTENSION_SEPARATOR); int pos2 = file_path.lastIndexOf(GetDirectorySeparator()); if (pos2 < pos) return file_path.substring(0, pos); else return file_path; } /** Returns the Directory Separator used in the current operating system Windows = \ Linux = / * * @return */ public static char GetDirectorySeparator() { return java.io.File.separatorChar; } }