List of utility methods to do File Path Create
String | buildPath(final boolean endWithSep, final String... val) Build a path out of the given elements. StringBuilder path = new StringBuilder(); for (String s : val) { if (s != null) { path.append(s); String s = path.toString().replaceAll("/+", "/"); if (endWithSep) { ... |
String | buildPath(final String basePath, final String path) build Path if (basePath == null && path == null) { return ""; if (basePath == null) { return path; if (path == null) { return basePath; ... |
String | buildPath(final String... tokens) build Path final StringBuilder sb = new StringBuilder(); for (final String token : tokens) { sb.append(TOKEN_PATH_SEPARATOR).append(token); return sb.toString(); |
String | buildPath(Integer sAccountId, String objectPath) build Path return ((sAccountId == null) ? "" : sAccountId + "/") + objectPath; |
String | buildPath(long id, boolean justDir) build Path StringBuilder fileBuffer = new StringBuilder(); fileBuffer.append(id); while ((fileBuffer.length() % 3) != 0) { fileBuffer.insert(0, '0'); StringBuilder dirBuffer = new StringBuilder(); for (int i = 0; i < fileBuffer.length() - 3; i += 3) { dirBuffer.append(fileBuffer.subSequence(i, i + 3)); ... |
String | buildPath(String first, String... parts) Concatenate path parts into a full path, taking care of extra or missing slashes. String result = first; for (String part : parts) { if (result.isEmpty()) { if (part.startsWith("/")) { result += part.substring(1); } else { result += part; } else { if (result.endsWith("/") && part.startsWith("/")) { result += part.substring(1); } else if (!result.endsWith("/") && !part.startsWith("/") && !part.isEmpty()) { result += "/" + part; } else { result += part; return result; |
String | buildPath(String part1, String part2) Takes two strings as input and builds a valid path out of them by placing a slash inbetween them. String retVal; if (part1.endsWith("/") && part2.startsWith("/")) { part1 = part1.substring(0, part1.length() - 1); retVal = part1 + part2; } else if (!part1.endsWith("/") && !part2.startsWith("/")) { retVal = part1 + "/" + part2; } else retVal = part1 + part2; ... |
String | buildPath(String path, String file) build Path if (path == null || path.isEmpty()) return file; else return path + "/" + file; |
String | buildPath(String... paths) Concatenates multiple string values together, ensuring that each value consists of only forward slashes. StringBuilder finalPath = new StringBuilder(); for (String path : paths) { path = path.replace("\\", "/"); if (finalPath.length() > 0) { if (finalPath.charAt(finalPath.length() - 1) != '/') { finalPath.append("/"); if (path.length() > 0 && path.charAt(0) == '/') { ... |
String | buildPath(String... strings) Builds a file path by concatenating the single strings and separating them with the system specific file separator character. StringBuilder sb = new StringBuilder(); for (String s : strings) { if (sb.length() != 0) sb.append(System.getProperty("file.separator")); sb.append(s); return sb.toString(); |