How to get value from properties file
To get information from the properties file, create the properties file first.
db.properties
- user=system
- password=oracle
Test.java
- import java.util.*;
- import java.io.*;
- public class Test {
- public static void main(String[] args)throws Exception{
- FileReader reader=new FileReader("db.properties");
-
- Properties p=new Properties();
- p.load(reader);
-
- System.out.println(p.getProperty("user"));
- System.out.println(p.getProperty("password"));
- }
- }
No comments:
Post a Comment