@Test public void normalizePathTest() { assertEquals(Paths.get(System.getProperty("user.home"), "Test", "Folder").toString(), FilesUtils.normalizePath("~/Test/Folder")); assertEquals(Paths.get(separator + "Test", "~", "Folder").toString(), FilesUtils.normalizePath("/Test/~/Folder")); assertEquals(Paths.get("~", "Test", "Folder").toString(), FilesUtils.normalizePath("./~/Test/Folder")); assertEquals(Paths.get(separator + "Folder").toString(), FilesUtils.normalizePath("/Test/../Folder")); assertEquals(Paths.get(separator + "Users", "Nikolas").toString(), FilesUtils.normalizePath("\\Users\\Nikolas\\")); }
public static String normalizePath(String pathString) { if (pathString != null && !pathString.isEmpty()) { if (pathString.indexOf("~") == 0) { pathString = System.getProperty("user.home") + (pathString.length() > 1 ? pathString.substring(1) : ""); } pathString = pathString.replace("/", File.separator); pathString = pathString.replace("\\", File.separator); Path p = Paths.get(pathString); pathString = p.normalize().toString(); return pathString; } return null; }
FilesUtils { public static String normalizePath(String pathString) { if (pathString != null && !pathString.isEmpty()) { if (pathString.indexOf("~") == 0) { pathString = System.getProperty("user.home") + (pathString.length() > 1 ? pathString.substring(1) : ""); } pathString = pathString.replace("/", File.separator); pathString = pathString.replace("\\", File.separator); Path p = Paths.get(pathString); pathString = p.normalize().toString(); return pathString; } return null; } }
FilesUtils { public static String normalizePath(String pathString) { if (pathString != null && !pathString.isEmpty()) { if (pathString.indexOf("~") == 0) { pathString = System.getProperty("user.home") + (pathString.length() > 1 ? pathString.substring(1) : ""); } pathString = pathString.replace("/", File.separator); pathString = pathString.replace("\\", File.separator); Path p = Paths.get(pathString); pathString = p.normalize().toString(); return pathString; } return null; } private  FilesUtils(); }
FilesUtils { public static String normalizePath(String pathString) { if (pathString != null && !pathString.isEmpty()) { if (pathString.indexOf("~") == 0) { pathString = System.getProperty("user.home") + (pathString.length() > 1 ? pathString.substring(1) : ""); } pathString = pathString.replace("/", File.separator); pathString = pathString.replace("\\", File.separator); Path p = Paths.get(pathString); pathString = p.normalize().toString(); return pathString; } return null; } private  FilesUtils(); static String getCachePathSetting(); static void setCachePathSetting(String cachePathSetting); static void resetDeployPath(); static String normalizePath(String pathString); static Path getDeployedPath(Path path); static void saveToFile(InputStream in, Path outFile); static void saveToFile(String content, Path outFile); static int getOffsetAfterScheme(String uri); static String getFilePathSlash(String text); static String convertToWindowsPath(String pathString); static boolean pathEndsWithFile(String pathString); static boolean isIncludedInDeployedPath(Path resourceCachePath); static String removeFileScheme(String fileURI); static Path getPath(String uri); static String encodePath(String path); }
FilesUtils { public static String normalizePath(String pathString) { if (pathString != null && !pathString.isEmpty()) { if (pathString.indexOf("~") == 0) { pathString = System.getProperty("user.home") + (pathString.length() > 1 ? pathString.substring(1) : ""); } pathString = pathString.replace("/", File.separator); pathString = pathString.replace("\\", File.separator); Path p = Paths.get(pathString); pathString = p.normalize().toString(); return pathString; } return null; } private  FilesUtils(); static String getCachePathSetting(); static void setCachePathSetting(String cachePathSetting); static void resetDeployPath(); static String normalizePath(String pathString); static Path getDeployedPath(Path path); static void saveToFile(InputStream in, Path outFile); static void saveToFile(String content, Path outFile); static int getOffsetAfterScheme(String uri); static String getFilePathSlash(String text); static String convertToWindowsPath(String pathString); static boolean pathEndsWithFile(String pathString); static boolean isIncludedInDeployedPath(Path resourceCachePath); static String removeFileScheme(String fileURI); static Path getPath(String uri); static String encodePath(String path); static final String FILE_SCHEME; static final String LEMMINX_WORKDIR_KEY; static Supplier<Path> DEPLOYED_BASE_PATH; }