/** * Get the parent directory of a file or directory. This method returns null * if there is no parent. This method is similar to Java 7 * <code>java.nio.file.Path.getParent</code>. * * @param fileName the file or directory name * @return the parent directory name */ public static String getParent(String fileName) { FilePath p = FilePath.get(fileName).getParent(); return p == null ? null : p.toString(); }