InputStream in = ReadProperties.class.getClassLoader() .getResourceAsStream("test.properties"); // 创建Properties实例 Properties prop = new Properties(); // 将Properties和流关联 prop.load(in); String name = prop.getProperty("default"); in.close();
ReadProperties 为当前所在类名