The java.util.Properties class in Java is used to manage application-specific properties. These properties are commonly stored in a file format and can be read and written to using this class. This class is part of the Java Collections Framework.
System.out.println(prop.getProperty("name")); // prints "John" System.out.println(prop.getProperty("age")); // prints "30"
This example creates a Properties object and adds two properties to it: the name and age of a person. The properties are then retrieved using the getProperty method.
Example 2:
Properties prop = new Properties(); InputStream input = getClass().getClassLoader().getResourceAsStream("config.properties");
prop.load(input);
System.out.println(prop.getProperty("db.url")); // prints the value of the "db.url" property
This example loads a set of properties from a configuration file called config.properties. The file is loaded as an input stream and passed to the load method of the Properties object. The value of a specific property is then retrieved using the getProperty method.
The java.util.Properties class is part of the core Java library, which means it is included in the java.util package.
Java Properties.list - 30 examples found. These are the top rated real world Java examples of java.util.Properties.list extracted from open source projects. You can rate examples to help us improve the quality of examples.