Here you can find the source of getFileName(String fullPath, boolean withParentFolder)
public static String getFileName(String fullPath, boolean withParentFolder)
//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*/ }