Java Path File Name nio getFileName(String fullPath, boolean withParentFolder)

Here you can find the source of getFileName(String fullPath, boolean withParentFolder)

Description

get File Name

License

Open Source License

Declaration

public static String getFileName(String fullPath, boolean withParentFolder) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.nio.file.Path;
import java.nio.file.Paths;

public class Main {
    public static String getFileName(String fullPath, boolean withParentFolder) {
        Path p = Paths.get(fullPath);

        String file = p.getFileName().toString();

        if (withParentFolder)
            file = p.getParent().getFileName() + "/" + file;
        return file;
    }/*from ww w  .  j  a v  a  2 s.c  o  m*/
}

Related

  1. getFilename (final String filepath)
  2. getFilename(final Path path)
  3. getFilename(final Path path)
  4. getFileName(Path path)
  5. getFileName(Path path)
  6. getFileName(String path)
  7. getFileName(String relativePath)
  8. getFileNameFromPath(String filePath)
  9. getFileNameFromPath(String str)