forked from RunningJon/outsourcer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOSProperties.java
73 lines (63 loc) · 1.99 KB
/
OSProperties.java
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.FileInputStream;
import java.util.Properties;
public class OSProperties
{
public static String osServer = "";
public static int osPort = 0;
public static String osHome = "";
public static String gpServer = "";
public static String gpDatabase = "";
public static int gpPort = 0;
public static String gpUserName = "";
public static String gpPassword = "";
public static void main(String[] args) throws Exception
{
String configFile = args[0];
getPropValues(configFile);
System.out.println("osServer: " + osServer);
System.out.println("osPort: " + osPort);
System.out.println("osHome: " + osHome);
System.out.println("gpServer: " + gpServer);
System.out.println("gpDatabase: " + gpDatabase);
System.out.println("gpPort: " + gpPort);
System.out.println("gpUserName: " + gpUserName);
System.out.println("gpPassword: " + gpPassword);
}
public static void getPropValues(String configFile) throws IOException
{
try
{
Properties prop = new Properties();
InputStream inputStream = new FileInputStream(configFile);
if (inputStream != null)
{
prop.load(inputStream);
}
else
{
throw new FileNotFoundException(configFile + " not found!");
}
// set the property values
osServer = prop.getProperty("osserver");
String strOsPort = prop.getProperty("osport");
if (strOsPort != null)
osPort = Integer.parseInt(strOsPort);
osHome = prop.getProperty("oshome");
gpServer = prop.getProperty("gpserver");
gpDatabase = prop.getProperty("gpdatabase");
String strGpPort = prop.getProperty("gpport");
if (strGpPort != null)
gpPort = Integer.parseInt(strGpPort);
gpUserName = prop.getProperty("gpusername");
gpPassword = prop.getProperty("gppassword");
}
catch (IOException iex)
{
System.out.println("Unable to read config.properties located here: " + configFile);
System.out.println(iex.getMessage());
}
}
}