赞
踩
- String path1 = ResourceUtils.getURL("classpath:static").getPath();
- String s = path1.replaceAll("%20", " ");
-
- String decode = URLDecoder.decode(path1, "utf-8");
- System.out.println(decode);
-
- System.out.println(path1);
- System.out.println(s);
- //利用System.getProperty()函数获取当前路径
- System.out.println(System.setProperty("user.dir", "c:users"));
- System.out.println(System.getProperty("user.dir"));//user.dir指定了当前的路径
-
- //在类中取得类的绝对路径
- System.out.println(Class.class.getClass().getResource("/").getPath());
- System.out.println(Thread.currentThread().getContextClassLoader().getResource("./static").getPath());
- System.out.println(Thread.currentThread().getContextClassLoader().getResource("").getPath());//ClassPath的绝对URI路径
- System.out.println(Thread.currentThread().getContextClassLoader().getResource(".").getPath());//项目的绝对路径
-
-
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。