forked from JavaOPs/basejava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfig.java
More file actions
42 lines (36 loc) · 1.16 KB
/
Config.java
File metadata and controls
42 lines (36 loc) · 1.16 KB
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
39
40
41
42
package com.urise.webapp;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.util.Properties;
public class Config {
protected static final File PROPS = new File(".\\storage\\resume.properties");
private static final Config INSTANCE = new Config();
private Properties props = new Properties();
private File storageDir;
private Config() {
try (InputStream is = new FileInputStream("./config/resumes.properties")) {
props.load(is);
storageDir = new File (props.getProperty("storage.dir"));
} catch (IOException e) {
throw new IllegalStateException("Invalid config file " +PROPS.getAbsolutePath());
}
}
public static Config getInstance() {
return INSTANCE;
}
public File getStorageDir() {
return storageDir;
}
public String getDbUrl (){
return props.getProperty("db.url");
}
public String getDbUser (){
return props.getProperty("db.user");
}
public String getDbPassword (){
return props.getProperty("db.password");
}
}