forked from anshulc55/JavaTraining
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWriteProperties.java
More file actions
38 lines (30 loc) · 838 Bytes
/
WriteProperties.java
File metadata and controls
38 lines (30 loc) · 838 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package utilities;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Properties;
public class WriteProperties {
public static void main(String[] args) {
Properties prop = new Properties();
OutputStream writeFile = null;
try {
writeFile = new FileOutputStream("config.properties");
prop.setProperty("DBServer", "ins01.kui02.anshul");
prop.setProperty("DBName", "db_anshul");
prop.setProperty("DBPass", "testpassword");
prop.setProperty("username", "root");
prop.store(writeFile, null);
System.out.println("Create Properties Successfully");
} catch (IOException io) {
io.printStackTrace();
} finally {
if (writeFile != null) {
try {
writeFile.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}