Here you can find the source of getRelativePath(String relativePathFile)
public static String getRelativePath(String relativePathFile) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.IOException; import java.nio.file.Path; import java.nio.file.Paths; public class Main { public static String getRelativePath(String relativePathFile) throws IOException { Path path = Paths.get(relativePathFile); return path.getFileName().toFile().getAbsolutePath(); }/*from ww w . j a v a2 s .c om*/ public static String getFileName(String relativePath) throws IOException { Path path = Paths.get(relativePath); return path.getFileName().toFile().getName(); } }