`

获取路径的方式

    博客分类:
  • JAVA
 
阅读更多
@Test
public void getClassPath(){

    ClassLoader loader = Thread.currentThread().getContextClassLoader();
    //获取当前classpath路径
System.out.println(loader.getResource("").getPath());
    //获取当前类的路径
System.out.println(this.getClass().getResource("").getPath());
    //获取当前classpath路径
System.out.println(this.getClass().getResource("/").getPath());
    //获取用户目录
System.out.println(System.getProperty("user.dir"));

    System.exit(0);
}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics