use of java.beans.XMLEncoder in project omegat by omegat-org.
the class SRX method saveTo.
/**
* Saves segmentation rules into specified file.
*/
public static void saveTo(SRX srx, File outFile) throws IOException {
if (srx == null) {
outFile.delete();
return;
}
try {
srx.setVersion(CURRENT_VERSION);
XMLEncoder xmlenc = new XMLEncoder(new FileOutputStream(outFile));
xmlenc.writeObject(srx);
xmlenc.close();
} catch (IOException ioe) {
Log.logErrorRB("CORE_SRX_ERROR_SAVING_SEGMENTATION_CONFIG");
Log.log(ioe);
throw ioe;
}
}
use of java.beans.XMLEncoder in project JavaYouShouldKnow by CFMystery.
the class JavaXml method saveToXML.
public void saveToXML(Object o) throws IOException {
File xmlFile = new File("file/out/object.xml");
if (!xmlFile.exists()) {
xmlFile.createNewFile();
}
FileOutputStream ofs = new FileOutputStream(xmlFile);
XMLEncoder xe = new XMLEncoder(ofs);
xe.writeObject(o);
xe.close();
ofs.close();
}
use of java.beans.XMLEncoder in project Java8 by huhuhuHR.
the class ObjectToXMLUtil method objectXmlEncode.
@SneakyThrows
public static void objectXmlEncode(Object obj, String fileName) {
var fo = new File(fileName);
if (fo.exists()) {
fo.delete();
}
fo.createNewFile();
@Cleanup var fos = new FileOutputStream(fo);
@Cleanup var encoder = new XMLEncoder(fos);
encoder.writeObject(obj);
encoder.flush();
}
use of java.beans.XMLEncoder in project java-swing-tips by aterai.
the class LoadSaveTask method saveWindowState.
protected static void saveWindowState(PersistenceService ps, URL codebase, WindowState windowState) {
try {
FileContents fc = ps.get(codebase);
try (XMLEncoder e = new XMLEncoder(new BufferedOutputStream(fc.getOutputStream(true)))) {
// Test: delete muf ex.
// C:\Users\(user)\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\muffin\xxx-xxx.muf
// ps.delete(codebase);
// ObjectOutputStream e = new ObjectOutputStream(fc.getOutputStream(true));
HashMap<String, Serializable> map = new HashMap<>();
map.put("size", (Serializable) windowState.getSize());
map.put("location", (Serializable) windowState.getLocation());
// Test1: map.put("setting", (Serializable) windowState);
// Test2: e.writeObject(windowState);
e.writeObject(map);
e.flush();
// e.close();
}
} catch (IOException ex) {
throw new UncheckedIOException(ex);
}
}
use of java.beans.XMLEncoder in project antlrworks by antlr.
the class XJDataXML method writeData.
@Override
public void writeData() throws IOException {
XMLEncoder e = new XMLEncoder(new BufferedOutputStream(new FileOutputStream(getFile())));
e.writeObject(dictionary);
customWriteData(e);
e.close();
}
Aggregations