Here you can find the source of getFileNameNoExtension(File file)
Parameter | Description |
---|---|
file | File to get filename from |
public static String getFileNameNoExtension(File file)
//package com.java2s; /*//w w w. j a v a 2s . c o m * Copyright (c) 2012 Diamond Light Source Ltd. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ import java.io.File; public class Main { /** * Get Filename minus it's extension if present * * @param file * File to get filename from * @return String filename minus its extension */ public static String getFileNameNoExtension(File file) { return getFileNameNoExtension(file.getName()); } /** * Get Filename minus it's extension if present * * @param fileName path to get filename of * @return String filename minus its extension */ public static String getFileNameNoExtension(String fileName) { int posExt = fileName.lastIndexOf("."); // No File Extension return posExt == -1 ? fileName : fileName.substring(0, posExt); } }