In this tutorial i am going to cover the topic how to read data from properties file in java.
properties file contains data in key and value formate
eg:
suppose i have a file inside my /src/main/resources folder name first.properties and contains data like
name = javaDream
age = 24
job_profile = software Developer
So if you want to read the data from first.properties then add the following code inside your main method
InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(“first.properties”);
Properties properties = new Properties();
properties.load(inputStream);
//For display name
System.out.println(properties.getProperty(“name “));
//For display Age
System.out.println(properties.getProperty(“age “));
//For display Job Profile
System.out.println(properties.getProperty(“job_profile “));