Java File Naked Name Get extractFileWithoutPath(String input)

Here you can find the source of extractFileWithoutPath(String input)

Description

extract File Without Path

License

Open Source License

Declaration

public static String extractFileWithoutPath(String input) 

Method Source Code

//package com.java2s;
/*//from   w ww . j ava  2 s  .co m
 * Keystone Development Framework
 * Copyright (C) 2004-2009 Rick Knowles
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public License
 * Version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License Version 2 for more details.
 *
 * You should have received a copy of the GNU Library General Public License
 * Version 2 along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */

public class Main {
    public static String extractFileWithoutPath(String input) {
        if (input == null) {
            return null;
        } else {
            int lastSlashPos = Math.max(input.lastIndexOf('/'), input.lastIndexOf('\\'));
            return (lastSlashPos == -1 ? input : input.substring(lastSlashPos + 1));
        }
    }
}

Related

  1. extractFileNameWithoutExt(String filePath)
  2. extractFileNameWithSuffix(String filePathName)
  3. extractFileWithoutExtension(String filename)
  4. fileNameWithoutExtension(String filename)
  5. filenameWithoutExtension(String filename)
  6. getFilenameNoExt(File f)
  7. getFileNameNoExt(File file)