Java File Name Get getFileName(File element)

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

Description

get File Name

License

Open Source License

Declaration

public static String getFileName(File element) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2009-2013 SKRATCHDOT.COM
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * http://www.eclipse.org/legal/epl-v10.html
 *  /*from   ww w  . j a v  a 2s  .c  o  m*/
 * Contributors:
 *     JEFF |:at:| SKRATCHDOT |:dot:| COM
 *******************************************************************************/

import java.io.File;

public class Main {
    public static String getFileName(File element) {
        String name = element.getName();
        return name.length() == 0 ? element.getPath() : name;
    }
}

Related

  1. getFileName(Class cls, String ext)
  2. getFileName(File f)
  3. getFileName(File f)
  4. getFileName(File f)
  5. getFileName(File file)