1
Code
2
Class MyClass
3![ExpandedBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
{
4
}
5
6
System.out.println(MyFile.
class
.getClassLoader().getResource(
""
));
//
Classes所在路径
7
System.out.println(ClassLoader.getSystemResource(
""
));
//
Classes所在路径
8
System.out.println(MyFile.
class
.getResource(
"
/
"
));
//
Classes所在路径
9
10
System.out.println(MyFile.
class
.getResource(
""
));
//
class所在路径
11
System.out.println(
new
File(
"
/
"
).getAbsolutePath());
//
盘符
12
System.out.println(System.getProperty(
"
user.dir
"
));
//
工程文件夹
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
2
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
3
![ExpandedBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![ContractedBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
![](https://www.cnblogs.com/Images/dot.gif)
4
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
5
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
6
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
7
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
8
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
9
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
10
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
11
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
12
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)