1
0
mirror of https://e.coding.net/circlecloud/CityBuild.git synced 2024-11-21 10:48:49 +00:00

update FileConfig class...

Signed-off-by: j502647092 <jtb1@163.com>
This commit is contained in:
j502647092 2015-05-30 17:37:01 +08:00
parent 56063ff2c2
commit 26fa367a06

View File

@ -1,5 +1,6 @@
package cn.citycraft.CityBuild.config;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
@ -7,6 +8,7 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.Reader;
import java.io.Writer;
import java.util.logging.Level;
@ -62,6 +64,22 @@ public class FileConfig extends YamlConfiguration {
final FileInputStream stream = new FileInputStream(file);
load(new InputStreamReader(stream, Charsets.UTF_8));
}
@Override
public void load(Reader reader) throws IOException, InvalidConfigurationException {
BufferedReader input = (reader instanceof BufferedReader) ? (BufferedReader) reader
: new BufferedReader(reader);
StringBuilder builder = new StringBuilder();
try {
String line;
while ((line = input.readLine()) != null) {
builder.append(line);
builder.append('\n');
}
} finally {
input.close();
}
loadFromString(builder.toString());
}
@Override
public void save(File file) throws IOException {