/**
*得到当前的classPath的绝对路径的URI几种表示法
*/
//3.得到的也是当前ClassPath的绝对URI路径。
System.out.println(Thread.currentThread().getContextClassLoader().getResource(""));
//4.得到的也是当前ClassPath的绝对URI路径。
// System.out.println(FilePath.class.getClassLoader().getResource(""));
//5.得到的也是当前ClassPath的绝对URI路径。
System.out.println(ClassLoader.getSystemResource(""));
//人为得到
System.out.println(new File("/").getAbsolutePath());
System.out.println(System.getProperty("user.dir"));
得到当前的classPath的绝对路径的URI几种表示法
最新推荐文章于 2021-07-19 16:15:00 发布
本文介绍了通过不同Java API获取当前ClassPath绝对路径的方法。包括使用Thread.currentThread().getContextClassLoader().getResource(); FilePath.class.getClassLoader().getResource(); ClassLoader.getSystemResource(); new File(/).getAbsolutePath(); System.getProperty(user.dir)等方法。
1万+

被折叠的 条评论
为什么被折叠?



