-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPropUpdate.java
More file actions
76 lines (63 loc) · 2.01 KB
/
PropUpdate.java
File metadata and controls
76 lines (63 loc) · 2.01 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package Jvakt;
/*
* 2022-06-23 V.54 Michael Ekdal Added getVersion() to get at consistent version throughout all classes.
*/
import java.io.*;
import java.net.*;
import java.util.*;
public class PropUpdate {
static String newmode = "";
static String oldmode = "";
static String config = null;
static File configF;
public static void main(String[] args ) throws IOException, UnknownHostException {
String version = "PropUpdate ";
version += getVersion()+".54";
for (int i=0; i<args.length; i++) {
if (args[i].equalsIgnoreCase("-config")) config = args[++i];
if (args[i].equalsIgnoreCase("-mode")) newmode = args[++i];
}
if (config == null ) configF = new File("Jvakt.properties");
else configF = new File(config,"Jvakt.properties");
System.out.println("----- Jvakt: "+new Date()+" Version: "+version);
System.out.println("-config file: "+configF);
Properties prop = new Properties();
InputStream input = null;
try {
input = new FileInputStream(configF);
prop.load(input);
// get the property value and print it out
oldmode = prop.getProperty("mode");
System.out.println("Old mode: " + oldmode);
input.close();
} catch (IOException ex) {
ex.printStackTrace();
}
// System.exit(0);
OutputStream output = null;
// FileWriter output = null;
try {
output = new FileOutputStream(configF);
// output = new FileWriter(configF);
// get the property value and print it out
System.out.println("New mode: " + newmode);
prop.setProperty("mode",newmode);
prop.store(output,null);
output.close();
} catch (IOException ex) {
ex.printStackTrace();
}
}
static private String getVersion() {
String version = "0";
try {
Class<?> c1 = Class.forName("Jvakt.Version",false,ClassLoader.getSystemClassLoader());
Version ver = new Version();
version = ver.getVersion();
}
catch (java.lang.ClassNotFoundException ex) {
version = "?";
}
return version;
}
}