The list of methods to do Path String Clean are organized into topic(s).
String
cleanPath(final String path) clean Path
String trimmed = path.trim();
if (!trimmed.startsWith("/"))
trimmed = "/" + trimmed;
if (trimmed.endsWith("/"))
trimmed = trimmed.substring(0, trimmed.length() - 1);
return trimmed;
String
cleanPath(final String url) Clean repeated // characters from the URL path.
return url.replaceAll("/+", "/").replaceAll("^((\\w)+:)/", "1ドル//").replaceAll("^file://", "file:///");
String
cleanPath(String loc) clean Path
if (loc.startsWith("reference:file:")) {
loc = loc.substring(15);
} else if (loc.startsWith("file:")) {
loc = loc.substring(5);
} else {
return loc;
loc = loc.replace("//", "/");
...
String
cleanPath(String path) clean path, remove double "/" and replace "\" by "/"
if (path == null) {
return null;
} else {
path = path.replace('\\', '/');
while (path.indexOf("//") >= 0) {
path = path.replace("//", "/");
return path;
...
String
cleanPath(String path) clean Path
if (path.endsWith("/")) {
path = path.replaceAll("/+$", "");
if (path.startsWith("/")) {
path = path.replaceAll("^/+", "");
return path.replaceAll("/+", "/");
String
cleanPath(String path) replace questionable chars in path with percent representation
String s;
s = path.replaceAll("#", "%23");
s = s.replaceAll(":", "%3A");
return s;
String
cleanPath(String path) Make sure the file separator is at the end of a given path.
if (!path.endsWith(System.getProperty("file.separator"))) {
path = path.concat(System.getProperty("file.separator"));
return path;
String
cleanPath(String path) Clean the path string by removing leading and trailing slashes and removing duplicate slashes.
if (path.endsWith(SEPARATOR)) {
path = path.replaceAll(SEPARATOR + "+$", "");
if (path.startsWith(SEPARATOR)) {
path = path.replaceAll("^" + SEPARATOR + "+", "");
return path.replaceAll("/+", SEPARATOR);
String
cleanPath(String path) Removes a trailing path separator.
String slash = System.getProperty("file.separator");
if (slash != null && slash.length() > 0) {
int len = path.length();
if (len > 0 && path.charAt(len - 1) == slash.charAt(0)) {
return path.substring(0, len - 1);
return path;
...
String
cleanPath(String path) clean Path
while (path.endsWith("/") && path.length() > 1) {
path = path.substring(0, path.length() - 1);
return path;