ITMISS
以下两种情况涉及从名为的示例类加载属性文件TestLoadProperties。案例1:使用加载属性文件 ClassLoaderInputStream inputStream = TestLoadProperties.class.getClassLoader()
.getResourceAsStream("A.config");properties.load(inputStream);在这种情况下,属性文件必须位于root/src目录中才能成功加载。案例2:不使用加载属性文件 ClassLoaderInputStream inputStream = getClass().getResourceAsStream("A.config");properties.load(inputStream);在这种情况下,属性文件必须与TestLoadProperties.class成功加载的文件位于同一目录中。注意: TestLoadProperties.java并且TestLoadProperties.class是两个不同的文件。前一个.java文件通常位于项目的src/目录中,而后一个.class文件通常位于其bin/目录中。