1、System.getProperty("user.dir") // 获取用户的当前工作路径
2、class.getProtectionDomain().getCodeSource().getLocation().getPath()//获取jar包路径地址
3、class.getResource(filePath)
/**
* 以class文件所在位置为起点,结合相对路径的概念,寻找文件;如果“/”开头,则是从根路径开始,即包含所有
* class文件的顶层目录,如WEB-INF中的classes目录;
*/
//与getResource相似,只不过使用new InputStream(path)获得字节流
class.getResourceAsStream(filePath)