本文整理了Java中java.beans.XMLEncoder.close()
方法的一些代码示例,展示了XMLEncoder.close()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XMLEncoder.close()
方法的具体详情如下:
包路径:java.beans.XMLEncoder
类名称:XMLEncoder
方法名:close
暂无
代码示例来源:origin: apache/shiro
/**
* Serializes the specified <code>source</code> into a byte[] array by using the
* {@link java.beans.XMLEncoder XMLEncoder} to encode the object out to a
* {@link java.io.ByteArrayOutputStream ByteArrayOutputStream}, where the resulting byte[] array is returned.
* @param source the Object to convert into a byte[] array.
* @return the byte[] array representation of the XML encoded output.
*/
public byte[] serialize(Object source) {
if (source == null) {
String msg = "argument cannot be null.";
throw new IllegalArgumentException(msg);
}
ByteArrayOutputStream bos = new ByteArrayOutputStream();
XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(bos));
encoder.writeObject(source);
encoder.close();
return bos.toByteArray();
}
代码示例来源:origin: oracle/opengrok
Project p1 = new Project("foo");
enc.writeObject(p1);
enc.close();
代码示例来源:origin: oracle/opengrok
Group g1 = new Group();
enc.writeObject(g1);
enc.close();
代码示例来源:origin: oracle/opengrok
e.setExceptionListener(listener);
e.writeObject(in);
e.close();
代码示例来源:origin: bobbylight/RSyntaxTextArea
new FileOutputStream(xmlFile)));
e.writeObject(template);
e.close();
} catch (IOException ioe) {
ioe.printStackTrace();
代码示例来源:origin: stackoverflow.com
import java.beans.XMLEncoder;
import java.beans.XMLDecoder;
import java.io.*;
public class XMLSerializer {
public static void write(String[][] f, String filename) throws Exception{
XMLEncoder encoder =
new XMLEncoder(
new BufferedOutputStream(
new FileOutputStream(filename)));
encoder.writeObject(f);
encoder.close();
}
public static String[][] read(String filename) throws Exception {
XMLDecoder decoder =
new XMLDecoder(new BufferedInputStream(
new FileInputStream(filename)));
String[][] o = (String[][])decoder.readObject();
decoder.close();
return o;
}
}
代码示例来源:origin: openpnp/openpnp
public static String serialize(Object o) {
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
XMLEncoder xmlEncoder = new XMLEncoder(bOut);
xmlEncoder.writeObject(o);
xmlEncoder.close();
return bOut.toString();
}
代码示例来源:origin: net.sf.czsem/czsem-common
public static void saveToFile(String filename, Map<String, Object> map) throws IOException
{
FileOutputStream os = new FileOutputStream(filename);
XMLEncoder encoder = new XMLEncoder(os);
encoder.writeObject(map);
encoder.close();
os.close();
}
代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-backend-common
@Override
public String marshall(final Metadata metadata) throws IOException {
ByteArrayOutputStream os = new ByteArrayOutputStream();
XMLEncoder encoder = new XMLEncoder(os);
encoder.writeObject(metadata);
encoder.close();
String raw = os.toString(CHARSET);
return raw;
}
}
代码示例来源:origin: stackoverflow.com
XMLEncoder e = new XMLEncoder(
new BufferedOutputStream(
new FileOutputStream("Test.xml")));
e.writeObject(dataList);
e.close();
代码示例来源:origin: com.intoverflow.base/intoverflow-util
public static String toXml(final Object o) {
ByteArrayOutputStream out = new ByteArrayOutputStream();
XMLEncoder e = new XMLEncoder(out);
e.writeObject(o);
e.flush();
e.close();
return new String(out.toByteArray());
}
代码示例来源:origin: com.haulmont.thirdparty/glazedlists
/** {@inheritDoc} */
public void encode(Object source, OutputStream target) throws IOException {
XMLEncoder xmlOut = new XMLEncoder(target);
xmlOut.writeObject(source);
xmlOut.close();
}
代码示例来源:origin: httl/httl
public byte[] toBytes(String key, Object value) {
ByteArrayOutputStream bo = new ByteArrayOutputStream();
XMLEncoder xe = new XMLEncoder(bo);
try {
xe.writeObject(value);
xe.flush();
} finally {
xe.close();
}
return bo.toByteArray();
}
代码示例来源:origin: net.sf.squirrel-sql/squirrel-sql
/**
* @see net.sourceforge.squirrel_sql.client.update.xmlbeans.UpdateXmlSerializer#write(net.sourceforge.squirrel_sql.client.update.xmlbeans.ChangeListXmlBean, java.lang.String)
*/
public void write(ChangeListXmlBean changeBean, String filename)
throws FileNotFoundException {
XMLEncoder os = getXmlEncoder(filename);
os.writeObject(changeBean);
os.close();
}
代码示例来源:origin: pl.edu.icm.yadda/yadda-analysis-impl
public static void storeXML(TreeMapMatrix<?, ?, ?> matrix, OutputStream os) {
XMLEncoder e = new XMLEncoder(os);
e.writeObject(matrix);
e.close();
}
代码示例来源:origin: realXuJiang/bigtable-sql
/**
* @see net.sourceforge.squirrel_sql.client.update.xmlbeans.UpdateXmlSerializer#write(net.sourceforge.squirrel_sql.client.update.xmlbeans.ChannelXmlBean, java.lang.String)
*/
public void write(ChannelXmlBean channelBean, String filename)
throws FileNotFoundException {
XMLEncoder os = getXmlEncoder(filename);
os.writeObject(channelBean);
os.close();
}
代码示例来源:origin: com.github.httl/httl
public byte[] toBytes(String key, Object value) {
ByteArrayOutputStream bo = new ByteArrayOutputStream();
XMLEncoder xe = new XMLEncoder(bo);
try {
xe.writeObject(value);
xe.flush();
} finally {
xe.close();
}
return bo.toByteArray();
}
代码示例来源:origin: stackoverflow.com
NPair fe = new NPair();
fe.setNumber1(12);
fe.setNumber2(13);
FileOutputStream fos1 = new FileOutputStream("d:\\ser.xml");
java.beans.XMLEncoder xe1 = new java.beans.XMLEncoder(fos1);
xe1.writeObject(fe);
xe1.flush();
xe1.close();
代码示例来源:origin: net.sf.squirrel-sql/squirrel-sql
/**
* @see net.sourceforge.squirrel_sql.client.update.xmlbeans.UpdateXmlSerializer#write(net.sourceforge.squirrel_sql.client.update.xmlbeans.ChangeListXmlBean, net.sourceforge.squirrel_sql.fw.util.FileWrapper)
*/
public void write(ChangeListXmlBean changeBean, FileWrapper file)
throws FileNotFoundException {
XMLEncoder os = getXmlEncoder(file.getAbsolutePath());
os.writeObject(changeBean);
os.close();
}
代码示例来源:origin: com.facebook.presto.hive/hive-apache
public static void serialize(OutputStream out, Object o)
{
XMLEncoder e = new XMLEncoder(out);
e.setExceptionListener(new EL());
PTFUtils.addPersistenceDelegates(e);
e.writeObject(o);
e.close();
}
内容来源于网络,如有侵权,请联系作者删除!