-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPTorchProperties.java
executable file
·70 lines (58 loc) · 1.48 KB
/
PTorchProperties.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
package com.gmail.fuzzelogicsoftware.PortableTorch;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;
public class PTorchProperties extends Properties{
private String fileName;
public PTorchProperties(String file) {
this.fileName = file;
}
public void load()
{
File file = new File(this.fileName);
if(file.exists()) {
try {
load(new FileInputStream(this.fileName));
} catch (IOException ex) {
}
}
}
public void save(String start){
try{
store(new FileOutputStream(this.fileName), start);
} catch (IOException ex) {
}
}
public int getInteger(String key, int value){
if(containsKey(key)){
return Integer.parseInt(getProperty(key));
}
put(key, String.valueOf(value));
return value;
}
public String getString(String key, String value){
if(containsKey(key)){
return getProperty(key);
}
put(key, value);
return value;
}
public Boolean getBoolean(String key, boolean value) {
if (containsKey(key)) {
String boolString = getProperty(key);
return (boolString.length() > 0)
&& (boolString.toLowerCase().charAt(0) == 't');
}
put(key, value ? "true" : "false");
return value;
}
public double getDouble(String key, double value) {
if (containsKey(key)) {
return Double.parseDouble(getProperty(key));
}
put(key, String.valueOf(value));
return value;
}
}