Here you can find the source of getFileNameWithoutExtension(String fileName)
Parameter | Description |
---|---|
fileName | a String containing the file name |
public static String getFileNameWithoutExtension(String fileName)
//package com.java2s; //License from project: Open Source License import java.io.File; public class Main { /**/*from w ww. ja v a 2 s . c om*/ * Returns a file's name, without its extension. * * @param fileName * a String containing the file name * @return a String containing the file name without extension */ public static String getFileNameWithoutExtension(String fileName) { int dotIndex = fileName.lastIndexOf('.'); return fileName.substring(0, dotIndex); } /** * Returns a file's name, without its extension. * * @param file * the file * @return a String containing the file name without extension */ public static String getFileNameWithoutExtension(File file) { return getFileNameWithoutExtension(file.getName()); } }