mirror of
https://github.com/2006-Scape/2006Scape.git
synced 2026-07-03 00:31:51 +00:00
2aef86ed25
Let me know how it works
38 lines
812 B
Java
38 lines
812 B
Java
package redone.util;
|
|
|
|
import java.io.File;
|
|
import java.io.FileOutputStream;
|
|
import java.io.IOException;
|
|
import com.thoughtworks.xstream.XStream;
|
|
|
|
import redone.game.npcs.NPCDefinition;
|
|
|
|
public class XStreamUtil {
|
|
|
|
private static XStreamUtil instance = new XStreamUtil();
|
|
private static XStream xStream = new XStream();
|
|
|
|
public static XStreamUtil getInstance() {
|
|
return instance;
|
|
}
|
|
|
|
static {
|
|
xStream.alias("npcDefinition", NPCDefinition.class);
|
|
}
|
|
|
|
public static XStream getXStream() {
|
|
return xStream;
|
|
}
|
|
|
|
public static void writeXML(Object object, File file) throws IOException {
|
|
FileOutputStream out = new FileOutputStream(file);
|
|
try {
|
|
xStream.toXML(object, out);
|
|
out.flush();
|
|
} finally {
|
|
out.close();
|
|
}
|
|
}
|
|
|
|
}
|