1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
public static String getAbsoluteClassPath(String classPath) {
String path = null; try { File file = new File(Thread.currentThread().getContextClassLoader().getResource(classPath).getPath()); path = URLDecoder.decode(file.getAbsolutePath(), "utf-8"); } catch (UnsupportedEncodingException e) { logger.error(e.getMessage(), e); } return path; }
public static String getRootAbsoluteClassPath() { String absoluteClassPath = getAbsoluteClassPath(); return absoluteClassPath.substring(0,absoluteClassPath.indexOf("WEB-INF")).replace('\\', '/');
}
|