1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| import java.io.IOException; import java.io.InputStream; import java.util.Properties;
public class InputProperties {
public static void main(String[] args) throws IOException { ClassLoader classLoader = InputProperties.class.getClassLoader(); InputStream inputStream = classLoader.getResourceAsStream("file.properties");
Properties properties = new Properties(); properties.load(inputStream); System.out.println(properties.getProperty("name")); System.out.println(properties.getProperty("age")); System.out.println(properties.getProperty("sex")); }
}
|