/***** This filename is config.properties # Database configuration db.url=jdbc:mysql://localhost:3306/mydatabase db.username=admin db.password=secret # Server configuration server.port=8080 server.host=localhost */ import java.io.FileInputStream; import java.io.IOException; import java.util.Properties; public class PropertyFileReader { public static void main(String[] args) { Properties properties = new Properties(); try (FileInputStream input = new FileInputStream("config.properties")) { // Load the properties file properties.load(input); // Retrieve values String dbUrl = properties.getProperty("db.url"); String dbUsername = properties.getProperty("db.username"); String dbPassword = properties.getProperty("db.password"); // Display values System.out.println("Database URL: " + dbUrl); System.out.println("Database Username: " + dbUsername); System.out.println("Database Password: " + dbPassword); } catch (IOException e) { e.printStackTrace(); } } }