本文整理汇总了Java中java.io.ObjectOutput.write方法的典型用法代码示例。如果您正苦于以下问题:Java ObjectOutput.write方法的具体用法?Java ObjectOutput.write怎么用?Java ObjectOutput.write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.io.ObjectOutput
的用法示例。
在下文中一共展示了ObjectOutput.write方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeSafely
import java.io.ObjectOutput; //导入方法依赖的package包/类
/** Writes an object safely to the object output.
* Can be read by {@link NbObjectInputStream#readSafely}.
* @param oo object output to write to
* @param obj the object to write
* @exception SafeException if the object simply fails to be serialized
* @exception IOException if something more serious fails
*/
public static void writeSafely(ObjectOutput oo, Object obj)
throws IOException {
ByteArrayOutputStream bos = new ByteArrayOutputStream(200);
try {
NbObjectOutputStream oos = new NbObjectOutputStream(bos);
oos.writeObject(obj);
oos.flush();
bos.close();
} catch (Exception exc) {
// exception during safe of the object
// encapsulate all exceptions into safe exception
oo.writeInt(0);
throw new SafeException(exc);
}
oo.writeInt(bos.size());
oo.write(bos.toByteArray());
}
示例2: writeExternal
import java.io.ObjectOutput; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void writeExternal( ObjectOutput out ) throws IOException
{
out.writeUTF( oid );
out.writeBoolean( criticality );
if ( hasValue() )
{
out.writeBoolean( true );
out.writeInt( value.length );
if ( value.length > 0 )
{
out.write( value );
}
}
else
{
out.writeBoolean( false );
}
out.flush();
}
示例3: writeExternal
import java.io.ObjectOutput; //导入方法依赖的package包/类
@Override
public void writeExternal(ObjectOutput out) throws IOException {
out.writeBoolean(reply);
out.writeInt(uuid.length);
out.write(uuid, 0, uuid.length);
out.writeInt(rpcId.length);
out.write(rpcId, 0, rpcId.length);
out.writeObject(message);
}
示例4: writeMembers
import java.io.ObjectOutput; //导入方法依赖的package包/类
/**
* @deprecated Unused - will be removed in 8.0.x
*/
@Deprecated
protected void writeMembers(ObjectOutput out, Member[] members) throws IOException {
if (members == null)
members = new Member[0];
out.writeInt(members.length);
for (int i = 0; i < members.length; i++) {
if (members[i] != null) {
byte[] d = members[i] != null ? ((MemberImpl) members[i]).getData(false) : new byte[0];
out.writeInt(d.length);
out.write(d);
}
}
}
示例5: writeExternal
import java.io.ObjectOutput; //导入方法依赖的package包/类
/**
* @see java.io.Externalizable#writeExternal
* @param out
* ObjectOutput
* @throws IOException
*/
@Override
public void writeExternal(ObjectOutput out) throws IOException {
out.writeInt(message != null ? message.length : 0);
if (message != null)
out.write(message, 0, message.length);
}
示例6: writeExternal
import java.io.ObjectOutput; //导入方法依赖的package包/类
@Override
public void writeExternal(ObjectOutput out) throws IOException {
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
writeToStream(baos);
final byte[] ba = baos.toByteArray();
out.writeInt(ba.length);
out.write(ba);
}
示例7: writeExternal
import java.io.ObjectOutput; //导入方法依赖的package包/类
/**
* The object implements the writeExternal method to save its contents
* by calling the methods of DataOutput for its primitive values or
* calling the writeObject method of ObjectOutput for objects, strings
* and arrays.
* @exception IOException Includes any I/O exceptions that may occur
*/
public void writeExternal(ObjectOutput out) throws IOException {
String s = toString(); // contains ASCII chars only
// one-to-one correspondence between ASCII char and byte in UTF string
if (s.length() <= 65535) { // 65535 is max length of UTF string
out.writeUTF(s);
} else {
out.writeByte(0);
out.writeByte(0);
out.writeInt(s.length());
out.write(s.getBytes());
}
}
示例8: writeExternal
import java.io.ObjectOutput; //导入方法依赖的package包/类
public void writeExternal(ObjectOutput out) throws IOException {
out.writeBoolean(this.buffer != null);
if (this.buffer != null) {
out.writeInt(this.buffer.capacity());
out.writeInt(this.buffer.limit());
out.writeInt(this.buffer.position());
for (int i = 0; i < this.buffer.capacity(); i++) {
out.write(this.buffer.get(i));
}
}
}
示例9: writeExternal
import java.io.ObjectOutput; //导入方法依赖的package包/类
@Override
public void writeExternal(ObjectOutput out) throws IOException {
out.writeInt(uuid.length);
out.write(uuid, 0, uuid.length);
out.writeInt(rpcId.length);
out.write(rpcId, 0, rpcId.length);
}
示例10: writeExternal
import java.io.ObjectOutput; //导入方法依赖的package包/类
/**
* The object implements the writeExternal method to save its contents by
* calling the methods of DataOutput for its primitive values or calling the
* writeObject method of ObjectOutput for objects, strings and arrays.
*
* @throws IOException Includes any I/O exceptions that may occur
*/
public void writeExternal(ObjectOutput out) throws IOException {
String s = toString(); // contains ASCII chars only
// one-to-one correspondence between ASCII char and byte in UTF string
if (s.length() <= 65535) { // 65535 is max length of UTF string
out.writeUTF(s);
} else {
out.writeByte(0);
out.writeByte(0);
out.writeInt(s.length());
out.write(s.getBytes());
}
}
示例11: writeExternal
import java.io.ObjectOutput; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void writeExternal( ObjectOutput out ) throws IOException
{
// Write a boolean for the HR flag
out.writeBoolean( isHR );
if ( isHR )
{
// Write the value if any
out.writeBoolean( upValue != null );
if ( upValue != null )
{
// Write the value
out.writeInt( bytes.length );
if ( bytes.length > 0 )
{
out.write( bytes );
}
}
// Write the prepared value if any
out.writeBoolean( normValue != null );
if ( normValue != null )
{
// Write the value
out.writeUTF( normValue );
}
}
else
{
// Just write the bytes if not null
out.writeBoolean( bytes != null );
if ( bytes != null )
{
out.writeInt( bytes.length );
if ( bytes.length > 0 )
{
out.write( bytes );
}
}
}
// and flush the data
out.flush();
}
示例12: writeExternal
import java.io.ObjectOutput; //导入方法依赖的package包/类
public void writeExternal(ObjectOutput out) throws IOException {
byte[] bytes = getBytes();
out.writeInt(bytes.length);
out.write(bytes);
}
示例13: writeExternal
import java.io.ObjectOutput; //导入方法依赖的package包/类
/**
* @see java.io.Externalizable#writeExternal
* @param out ObjectOutput
* @throws IOException
*/
@Override
public void writeExternal(ObjectOutput out) throws IOException {
out.writeInt(message!=null?message.length:0);
if ( message!=null ) out.write(message,0,message.length);
}
示例14: writeExternal
import java.io.ObjectOutput; //导入方法依赖的package包/类
@Override
public final void writeExternal(final ObjectOutput out) throws IOException {
out.writeInt(serialized.length);
out.write(serialized);
}
示例15: writeExternal
import java.io.ObjectOutput; //导入方法依赖的package包/类
@Override
public void writeExternal(final ObjectOutput out) throws IOException {
out.writeInt(serialized.length);
out.write(serialized);
}