99 public static void load() {
100 if (!Files.exists(FILE_PATH))
return;
102 final Type type =
new TypeToken<Map<String, Profile>>() {
105 try (
final FileReader reader =
new FileReader(FILE_PATH.toFile())) {
106 profiles =
GsonUtils.json().fromJson(reader, type);
107 }
catch (
final Exception e) {
114 Thread.startVirtualThread(() -> {
116 final Path path = FILE_PATH;
117 Path parent = path.getParent();
118 if (parent ==
null) {
119 throw new UnsupportedOperationException(
"Path must have a parent " + path);
121 if (!Files.exists(parent)) {
122 parent = Files.createDirectories(parent);
125 final Path tempFile = Files.createTempFile(parent, path.getFileName().toString(),
".tmp");
126 Files.write(tempFile,
GsonUtils.json().toJson(profiles).getBytes());
128 Files.move(tempFile, path, StandardCopyOption.ATOMIC_MOVE, StandardCopyOption.REPLACE_EXISTING);
129 }
catch (
final Exception e) {