How to easily read data from properties file in Java

How to easily read data from .properties file in Java.

Properties files are in this format: key = value, where each key is on one line. You can easily read properties from some file using object of type Propeties, but first you must open a stream. Next create instance of class Properties and load properties from file. After that you can easily get properties using method getProperty(key) and the result will be value from properties file.

try (FileReader reader = new FileReader("db.properties")) {
	Properties properties = new Properties();
	properties.load(reader);
	String url = properties.getProperty("db.url");
	System.out.println(url);
} catch (IOException e) {
	e.printStackTrace();
}