Java Path File Name nio getPath(final String fullFileName)

Here you can find the source of getPath(final String fullFileName)

Description

Returns the path (without the file-name) for a filename with path.

License

Microsoft Public License

Parameter

Parameter Description
fullFileName String the full file name

Return

the path as a string

Declaration

public static String getPath(final String fullFileName) 

Method Source Code

//package com.java2s;
/**************************************************************************
 * <pre>/*from   w w w .  j  a va  2s  .c o m*/
 *
 * Copyright (c) Unterrainer Informatik OG.
 * This source is subject to the Microsoft Public License.
 *
 * See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
 * All other rights reserved.
 *
 * (In other words you may copy, use, change and redistribute it without
 * any restrictions except for not suing me because it broke something.)
 *
 * THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
 * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
 * PURPOSE.
 *
 * </pre>
 ***************************************************************************/

import java.nio.file.Paths;

public class Main {
    /**
     * Returns the path (without the file-name) for a filename with path.
     *
     * @param fullFileName {@link String} the full file name
     * @return the path as a string
     */
    public static String getPath(final String fullFileName) {
        return Paths.get(fullFileName).getParent().toString();
    }
}

Related

  1. getNormalizedFileName(Path file)
  2. getPackageURI(String pkgName, String pkgPath, String currentPkgName)
  3. getPath(Class example, String filename)
  4. getPath(Class baseClass, String resourceName)
  5. getPath(File dir, String filename)
  6. getPath(Object name)
  7. getPath(String dirName, String fileName)
  8. getPathByClassName(Class clazz, String relativeDir)
  9. getPathByFilename(String filename, List files)