PathUtils { public static String extractPath(String nameWithPath) { int index = nameWithPath.lastIndexOf(UNIX_PATH_SEPARATOR); return index > -1 ? nameWithPath.substring(0, index + 1) : ""; } private  PathUtils(); static String unixPath(@NotNull String first, String... more); static String unixPath(@NotNull Path path); @NotNull static String unixPathEndingWithSeparator(@NotNull String first, String... more); @NotNull static String unixPathEndingWithSeparator(@NotNull Path path); static String extractName(String nameWithPath); static String extractPath(String nameWithPath); static String extractNameFromUniqueEntityName(String uniqueName);  }
@Test void testExtractPath() { assertEquals("", PathUtils.extractPath("test")); assertEquals("path/", PathUtils.extractPath("path/test")); assertEquals("/path/subpath/", PathUtils.extractPath("/path/subpath/test")); }