Skip to content

Commit fa458ca

Browse files
committed
Remove PathUtil
1 parent d0f3777 commit fa458ca

2 files changed

Lines changed: 10 additions & 192 deletions

File tree

src/main/java/com/flowpowered/commons/PathUtil.java

Lines changed: 0 additions & 184 deletions
This file was deleted.

src/main/java/com/flowpowered/commons/store/FlatFileStore.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,14 @@
2424
package com.flowpowered.commons.store;
2525

2626
import java.io.IOException;
27+
import java.nio.charset.Charset;
2728
import java.nio.file.Files;
2829
import java.nio.file.Path;
2930
import java.util.ArrayList;
3031
import java.util.Collection;
3132
import java.util.Iterator;
3233
import java.util.Map.Entry;
3334

34-
import com.flowpowered.commons.PathUtil;
35-
3635
/**
3736
* This implements a SimpleStore that is stored in memory. The save and load methods can be used to write the map to a File.
3837
*/
@@ -69,18 +68,21 @@ public synchronized boolean save() {
6968
}
7069

7170
Collection<String> strings = getStrings();
72-
boolean saved = PathUtil.stringToFile(strings, path);
73-
if (saved) {
71+
try {
72+
Files.write(path, strings, Charset.defaultCharset());
7473
dirty = false;
74+
return true;
75+
} catch (IOException e) {
76+
return false;
7577
}
76-
77-
return saved;
7878
}
7979

8080
@Override
8181
public synchronized boolean load() {
82-
Collection<String> strings = PathUtil.fileToString(path);
83-
if (strings == null) {
82+
Collection<String> strings;
83+
try {
84+
strings = Files.readAllLines(path, Charset.defaultCharset());
85+
} catch (IOException e) {
8486
return false;
8587
}
8688
boolean loaded = processStrings(strings);

0 commit comments

Comments
 (0)