mirror of
https://github.com/2006-Scape/2006Scape.git
synced 2026-07-04 00:31:54 +00:00
committed by
Daniel Ginovker
parent
6cda5d5c78
commit
2aef86ed25
@@ -0,0 +1,37 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user