Here you can find the source of getFileNameNoSuffix(String path)
Parameter | Description |
---|---|
path | a parameter |
public static String getFileNameNoSuffix(String path)
//package com.java2s; /**// w w w . j av a 2s . c om * nz.govt.natlib.ndha.common.Common - Software License * * Copyright 2007/2008 National Library of New Zealand. * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * or the file "LICENSE.txt" included with the software. * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or * implied. See the License for the specific language governing * permissions and limitations under the License. * * FileUtils.java * $Rev$ * PlayerM * 26/11/2007 * */ import java.io.File; public class Main { /** * Get just the file name without a suffix from a path * * @param path * @return */ public static String getFileNameNoSuffix(String path) { return getFileNameNoSuffix(new File(path)); } /** * Get just the file name without a suffix from a file * * @param file * @return */ public static String getFileNameNoSuffix(File file) { String fileName = file.getName(); int dotPos = fileName.lastIndexOf("."); if (dotPos >= 0) { fileName = fileName.substring(0, dotPos); } return fileName; } }