1、ReadSurce.class.getClassLoader().getResourceAsStream("data.properties");
Profile data.properties, under src directory, by the class loader, loading files. When a file is labeled jar package, the method is preferably used.
2、ReadSurce.class.getResourceAsStream("data2.properties");
Configuration file in the package directory ReadSurce this class, that is resurce this package below.
3. Compare
ReadSurce.class.getClassLoader().getResourceAsStream("data.properties"); ReadSurce.class.getResourceAsStream("data2.properties");