Java File Name Get getFileName(File file)

Here you can find the source of getFileName(File file)

Description

Returns file name.

License

LGPL

Parameter

Parameter Description
file the file

Return

name of the file

Declaration

public static String getFileName(File file) 

Method Source Code

//package com.java2s;
/*/*from  w w  w .  j av a2  s.c o  m*/
 *   This software is distributed under the terms of the FSF 
 *   Gnu Lesser General Public License (see lgpl.txt). 
 *
 *   This program is distributed WITHOUT ANY WARRANTY. See the
 *   GNU General Public License for more details.
 */

import java.io.File;

public class Main {
    /**
     * Returns file name.
     * 
     * @param file  the file
     * @return name of the file
     */
    public static String getFileName(File file) {
        return (file != null) ? file.getName() : "";
    }
}

Related

  1. getFileName(File element)
  2. getFileName(File f)
  3. getFileName(File f)
  4. getFileName(File f)
  5. getFileName(File file)
  6. getFileName(File file)
  7. getFileName(File file)
  8. getFilename(File file)
  9. getFileName(File file)