一:

//获取properties对象
Properties prop=new Properties();
InputStream in=Object.class.getResourceAdAtream("/test.properties");
InputStream in=this.class.getResourceAdAtream("/test.properties");

二:

//获取当前类所在的包
File fileB = newthis.getClass().getResource("").getPath());

三:

//获取当前类所在的工程名
System.getProperties("");

四:

//利用反射方式获取路径

InputStream ips1 = Enumeration.class.getClassLoader() .getResourceAsStream("cn/zhao/enumStudy/testPropertiesPath1.properties");
         
InputStream ips2 = Enumeration.class.getResourceAsStream("testPropertiesPath1.properties");
         
InputStream ips3 = Enumeration.class.getResourceAsStream("properties/testPropertiesPath2.properties");