perf: 优化性能

This commit is contained in:
2022-11-07 00:33:43 +08:00
parent 7ea096d5fd
commit 6eddc99b02

View File

@@ -26,9 +26,10 @@ public final class ServerConfig {
@SuppressWarnings("unchecked")
public static void init() throws IOException {
File configFile = new File("config.yml");
InputStream stream = Files.newInputStream(configFile.toPath());
Map<String, Object> map = new Yaml().load(stream);
stream.close();
Map<String, Object> map;
try (InputStream stream = Files.newInputStream(configFile.toPath())) {
map = new Yaml().load(stream);
}
host = (String) map.get("host");
port = (int) map.get("port");