Here you can find the source of getFileName(Path path)
Parameter | Description |
---|---|
path | a parameter |
public static String getFileName(Path path)
//package com.java2s; /******************************************************************************* * File: PathUtils.java//from w w w.j a v a 2s.com * * Date: 2014/08/11 * Author: Mikhail Niedre * * Copyright (c) 2014 Original authors and others. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * <a href="http://www.eclipse.org/legal/epl-v10.html">epl-v1.0</a> * * Contributors: * Mikhail Niedre - initial API and implementation *******************************************************************************/ import java.nio.file.Path; public class Main { /** * Root path have no file name. * * TODO rework extra symbols * * @param path * @return file name */ public static String getFileName(Path path) { String pathString = null; if (path != null) { if (path.getFileName() != null) { pathString = path.getFileName().toString(); } else { pathString = path.toString(); } } return pathString; } }