-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathproperties.java
More file actions
52 lines (48 loc) · 1.15 KB
/
Copy pathproperties.java
File metadata and controls
52 lines (48 loc) · 1.15 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
43
44
45
46
47
48
49
50
51
52
package javaforce.utils;
import java.io.*;
import java.util.*;
import javaforce.*;
/** properties.
*
* CLI to view properties (works with yaml files too)
*
* @author peter.quiring
*/
public class properties {
public static void main(String[] args) {
if (args.length == 0) {
usage();
}
try {
switch (args[0]) {
case "read":
if (args.length < 3) {
usage();
}
Properties props = new Properties();
props.load(new FileInputStream(args[1]));
String prop = (String)props.get(args[2]);
if (prop == null) {
error("property not found");
}
System.out.print(prop);
break;
default:
System.out.println("Error:Unknown command");
System.exit(1);
break;
}
} catch (Exception e) {
JFLog.log(e);
}
}
private static void usage() {
System.out.println("Usage:properties {cmd} [args]");
System.out.println(" cmd:read {file} {property}");
System.exit(1);
}
private static void error(String msg) {
System.out.println("Error:" + msg);
System.exit(1);
}
}