public class PathUtils {
public String getPath() {
String webPath = this.getClass().getResource("/").getPath()
.replaceAll("^\\/", "");
webPath = webPath.replaceAll(
"[\\\\\\/]WEB-INF[\\\\\\/]classes[\\\\\\/]?", "/");
webPath = webPath.replaceAll("[\\\\\\/]+", "/");
webPath = webPath.replaceAll("%20", " ");
if (webPath.matches("^[a-zA-Z]:.*?$")) {
} else {
webPath = "/" + webPath;
}
webPath += "/";
webPath = webPath.replaceAll("[\\\\\\/]+", "/");
System.out.println(webPath);
return webPath;
}
public static void main(String[] args){
System.out.println(new PathUtils().getPath());
}
public String getPath() {
String webPath = this.getClass().getResource("/").getPath()
.replaceAll("^\\/", "");
webPath = webPath.replaceAll(
"[\\\\\\/]WEB-INF[\\\\\\/]classes[\\\\\\/]?", "/");
webPath = webPath.replaceAll("[\\\\\\/]+", "/");
webPath = webPath.replaceAll("%20", " ");
if (webPath.matches("^[a-zA-Z]:.*?$")) {
} else {
webPath = "/" + webPath;
}
webPath += "/";
webPath = webPath.replaceAll("[\\\\\\/]+", "/");
System.out.println(webPath);
return webPath;
}
public static void main(String[] args){
System.out.println(new PathUtils().getPath());
}