Using Properties Files in Java


Properties files (.properties) are simple key-value pair files used for configuration. They can be easily loaded into your Java application.

Source Code

Properties prop = new Properties();
InputStream input = new FileInputStream("config.properties");
prop.load(input);
System.out.println(prop.getProperty("database.url"));

Utilize properties files to externalize configuration from your Java code, making it easier to modify settings without changing the source code.

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments