Here you can find the source of getFileNameWithoutExt(String originPath)
Parameter | Description |
---|---|
originPath | The complete path. |
public static String getFileNameWithoutExt(String originPath)
//package com.java2s; import java.io.File; public class Main { /**// www. j a v a2 s . c o m * Get the file name without extension, given a complete path. * @param originPath The complete path. * @return */ public static String getFileNameWithoutExt(String originPath) { String name = ""; try { String fileName = getFileName(originPath); name = fileName.substring(0, fileName.lastIndexOf('.')); } catch (Exception e) { e.printStackTrace(); } return name; } /** * Get the file name, given a complete path. * @param originPath The complete path. * @return */ public static String getFileName(String originPath) { String file = ""; try { file = originPath.substring(originPath.lastIndexOf(File.separatorChar) + 1); } catch (Exception e) { e.printStackTrace(); } return file; } }