Return to Snippet

Revision: 5062
at February 8, 2008 09:06 by pmatrasc


Initial Code
public static String getFileNameWithoutExtension(String fileName) {
        File tmpFile = new File(fileName);
        tmpFile.getName();
        int whereDot = tmpFile.getName().lastIndexOf('.');
        if (0 < whereDot && whereDot <= tmpFile.getName().length() - 2 ) {
            return tmpFile.getName().substring(0, whereDot);
            //extension = filename.substring(whereDot+1);
        }    
        return "";
    }

Initial URL
blog.paolomatrascia.com

Initial Description

                                

Initial Title
Extract the file name (without the extension) from a full pathname

Initial Tags
file

Initial Language
Java