本文整理汇总了Java中de.ruedigermoeller.serialization.FSTObjectOutput.writeObject方法的典型用法代码示例。如果您正苦于以下问题:Java FSTObjectOutput.writeObject方法的具体用法?Java FSTObjectOutput.writeObject怎么用?Java FSTObjectOutput.writeObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类de.ruedigermoeller.serialization.FSTObjectOutput
的用法示例。
在下文中一共展示了FSTObjectOutput.writeObject方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fstWithFactory
import de.ruedigermoeller.serialization.FSTObjectOutput; //导入方法依赖的package包/类
/**
* fst 序列化
*
* use simple factory method to obtain input/outputstream instances. it is
* thread safe.
*
* object -> byte[]
*
* @param value
* @param outputStream
* @return
*/
public static boolean fstWithFactory(Object value, OutputStream outputStream) {
AssertHelper.notNull(value, "The Value must not be null");
AssertHelper.notNull(outputStream, "The OutputStream must not be null");
//
boolean result = false;
FSTObjectOutput out = null;
try {
out = fstConfiguration.getObjectOutput(outputStream);
out.writeObject(value);
result = true;
} catch (Exception e) {
LOGGER.error(new StringBuilder("Exception encountered during fstWithFactory()").toString(), e);
} finally {
try {
if (out != null) {
// DON'T out.close() when using factory method;
out.flush();
}
} catch (Exception ex) {
}
}
return result;
}
示例2: serialize
import de.ruedigermoeller.serialization.FSTObjectOutput; //导入方法依赖的package包/类
/**
* Get the bytes representing the given serialized object.
*/
protected byte[] serialize(Object o) {
if (o == null) {
throw new NullPointerException("Can't serialize null");
}
byte[] rv = null;
try {
FSTObjectOutput os = conf.getObjectOutput();
os.writeObject(o);
os.flush();
rv = os.getCopyOfWrittenBuffer();
} catch (IOException e) {
throw new IllegalArgumentException("Non-serializable object", e);
}
return rv;
}
示例3: marshal
import de.ruedigermoeller.serialization.FSTObjectOutput; //导入方法依赖的package包/类
@Override
public void marshal(OutputStream stream, Object obj) {
FSTObjectOutput out = conf.getObjectOutput(stream);
try {
out.writeObject( obj, Mesh.class );
out.flush();
} catch (IOException e) {
e.printStackTrace();
}
}
示例4: encode
import de.ruedigermoeller.serialization.FSTObjectOutput; //导入方法依赖的package包/类
@Override
public void encode(OutputStream out, Serializable msg) throws Exception
{
FSTObjectOutput fout = conf.getObjectOutput(out);
fout.writeObject(msg);
fout.flush();
out.close();
}
示例5: serialize
import de.ruedigermoeller.serialization.FSTObjectOutput; //导入方法依赖的package包/类
@Override
public <T> byte[] serialize(T obj) throws IOException {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
FSTObjectOutput out = conf.getObjectOutput(bos);
out.writeObject( obj, Bean.class );
out.flush();
return bos.toByteArray();
}
示例6: serialize
import de.ruedigermoeller.serialization.FSTObjectOutput; //导入方法依赖的package包/类
/**
* Serializes the whole object to the provided stream using FST library.
* <b>It will close the input stream when it's finished.</b>
* @param toSerialize the object to be serialized
* @param os the stream to which to serialize
* @throws java.io.IOException
*/
public static void serialize(Object toSerialize, OutputStream os) throws IOException {
FSTObjectOutput out = conf.getObjectOutput(os);
out.writeObject(toSerialize);
os.close();
}