当前位置: 首页>>代码示例>>Java>>正文


Java ObjectOutput.write方法代码示例

本文整理汇总了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());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:NbObjectOutputStream.java

示例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();
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:27,代码来源:LdifControl.java

示例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);
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:10,代码来源:RpcMessage.java

示例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);
		}
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:17,代码来源:AbstractReplicatedMap.java

示例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);
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:13,代码来源:ByteMessage.java

示例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);
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:9,代码来源:LoopedAbstractDrillSerializable.java

示例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());
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:MimeType.java

示例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));
    }
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:12,代码来源:ByteBufferInputStream.java

示例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);
}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:8,代码来源:RpcMessage.java

示例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());
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:MimeType.java

示例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();
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:54,代码来源:Value.java

示例12: writeExternal

import java.io.ObjectOutput; //导入方法依赖的package包/类
public void writeExternal(ObjectOutput out) throws IOException {
  byte[] bytes = getBytes();
  out.writeInt(bytes.length);
  out.write(bytes);
}
 
开发者ID:huang-up,项目名称:mycat-src-1.6.1-RELEASE,代码行数:6,代码来源:UTF8String.java

示例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);
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:11,代码来源:ByteMessage.java

示例14: writeExternal

import java.io.ObjectOutput; //导入方法依赖的package包/类
@Override
public final void writeExternal(final ObjectOutput out) throws IOException {
    out.writeInt(serialized.length);
    out.write(serialized);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:6,代码来源:AbstractIdentifiablePayload.java

示例15: writeExternal

import java.io.ObjectOutput; //导入方法依赖的package包/类
@Override
public void writeExternal(final ObjectOutput out) throws IOException {
    out.writeInt(serialized.length);
    out.write(serialized);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:6,代码来源:MemberName.java


注:本文中的java.io.ObjectOutput.write方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。