Here you can find the source of fileName(String filename)
Parameter | Description |
---|---|
filename | The name of the file whose name (without extension) we want |
public static String fileName(String filename)
//package com.java2s; //License from project: Open Source License public class Main { /*********************************************************** * @param filename//from ww w .j a v a 2 s . co m * The name of the file whose name (without extension) we want ***********************************************************/ public static String fileName(String filename) { String name = ""; int i = filename.lastIndexOf('.'); int p = Math.max(filename.lastIndexOf('/'), filename.lastIndexOf('\\')); if (i > p) { name = filename.substring(0, i); } return name; } }