此函数用于获取文件路径上的最后一个元素。
//时代Java //package com.nowjava; import java.io.File; import java.nio.file.Paths; public class Main { /** * This function is used to get the last element on a file path. The last * element is the last file/ directory on the path. * * @param path * is the path under query. * @return * the last element of the given path. */ public static String getLastElementOfPath(String path) { return Paths.get(path).getFileName().toString(); } public