-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathUtilities.java
More file actions
36 lines (31 loc) · 1.42 KB
/
Utilities.java
File metadata and controls
36 lines (31 loc) · 1.42 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
package example;
import client.*;
import java.nio.file.Paths;
import java.util.Properties;
import java.io.IOException;
import java.io.InputStream;
import java.io.FileInputStream;
import java.util.Properties;
import java.time.LocalDateTime;
import com.carrotsearch.hppc.IntObjectMap;
public class Utilities {
private static Properties properties = new Properties();
private static void loadProperties(Properties properties) throws IOException {
try (InputStream inputStream = new FileInputStream(Paths.get("").toAbsolutePath().getParent() + "/ClientSimulator/build/install/ClientSimulator/resources/simulation.properties")) {
if (inputStream != null) {
properties.load(inputStream);
} else {
throw new IOException("Unable to load properties file simulation.properties");
}
}
}
public static Client loadClientData(int clientId, int securityId) throws Exception {
loadProperties(properties);
String dataPath = properties.get("DATA_PATH").toString();
IntObjectMap<ClientData> clientData = ClientData.loadClientDataData(dataPath);
Client client = new Client(clientData.get(clientId), securityId);
client.init(properties);
return client;
}
//------------------------------------------------------------------------------------------------------------------
}