java.io.ObjectOutput#flush ( )源码实例Demo

下面列出了java.io.ObjectOutput#flush ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: directory-ldap-api   文件: DefaultModification.java
/**
 * @see java.io.Externalizable#writeExternal(ObjectOutput)
 */
@Override
public void writeExternal( ObjectOutput out ) throws IOException
{
    // The operation
    out.writeInt( operation.getValue() );

    // The EntryAttribute if not null
    if ( attribute != null )
    {
        out.writeBoolean( true );
        attribute.writeExternal( out );
    }
    else
    {
        out.writeBoolean( false );
    }

    out.flush();
}
 
源代码2 项目: tomee   文件: EJBRequest.java
/**
 * Write to server.
 * WARNING: To maintain backwards compatibility never change the order or insert new writes, always append to
 * {@link org.apache.openejb.client.EJBRequest.Body#writeExternal(java.io.ObjectOutput)}
 *
 * @param out ObjectOutput
 * @throws IOException
 */
@Override
public void writeExternal(final ObjectOutput out) throws IOException {

    out.writeByte(requestMethod.getCode());

    if (deploymentCode > 0) {
        out.writeObject(null);
    } else {
        out.writeObject(deploymentId);
    }

    out.writeShort(deploymentCode);
    out.writeObject(clientIdentity);
    out.writeInt(serverHash);
    out.flush();

    body.setMetaData(metaData);
    body.writeExternal(out);
}
 
源代码3 项目: directory-ldap-api   文件: LdifControl.java
/**
 * {@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();
}
 
源代码4 项目: directory-ldap-api   文件: Dn.java
/**
 * {@inheritDoc}
 */
@Override
public void writeExternal( ObjectOutput out ) throws IOException
{
    if ( upName == null )
    {
        String message = I18n.err( I18n.ERR_13624_CANNOT_SERIALIZE_NULL_DN );
        LOG.error( message );
        throw new IOException( message );
    }

    // Write the UPName
    out.writeUTF( upName );

    // Write the RDNs.
    // First the number of RDNs
    out.writeInt( size() );

    // Loop on the RDNs
    for ( Rdn rdn : rdns )
    {
        rdn.writeExternal( out );
    }

    out.flush();
}
 
源代码5 项目: HotswapAgent   文件: JdkPluginTest.java
private byte[] writeObject(Object o) throws IOException {
    try (ByteArrayOutputStream  bos = new ByteArrayOutputStream()) {
        ObjectOutput out = new ObjectOutputStream(bos);
        out.writeObject(o);
        out.flush();
        return bos.toByteArray();
    }
}
 
源代码6 项目: kogito-runtimes   文件: DroolsObjectIOTest.java
private static byte[] serialize(Object obj) throws IOException {
    ByteArrayOutputStream   bytes   = new ByteArrayOutputStream();
    ObjectOutput            out = new DroolsObjectOutputStream(bytes);

    out.writeObject(obj);
    out.flush();
    out.close();

    return bytes.toByteArray();
}
 
源代码7 项目: kogito-runtimes   文件: DroolsObjectIOTest.java
private static byte[] marshal(Object obj) throws IOException {
    ByteArrayOutputStream   bytes   = new ByteArrayOutputStream();
    ObjectOutput            out = new ObjectOutputStream(bytes);

    out.writeObject(obj);
    out.flush();
    out.close();

    return bytes.toByteArray();
}
 
源代码8 项目: cacheonix-core   文件: ByteArrayKeyTest.java
public void testReadWriteExternal() throws IOException, ClassNotFoundException {

      final ByteArrayOutputStream baos = new ByteArrayOutputStream(100);
      final ObjectOutput oos = new ObjectOutputStream(baos);
      oos.writeObject(byteArrayKey);
      oos.flush();

      assertEquals(byteArrayKey, new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray())).readObject());
   }
 
源代码9 项目: yauaa   文件: TestJavaSerialization.java
byte[] serialize(UserAgentAnalyzerTester uaa) throws IOException {
    try (ByteArrayOutputStream bos = new ByteArrayOutputStream()) {
        ObjectOutput out = new ObjectOutputStream(bos);
        out.writeObject(uaa);
        out.flush();
        return bos.toByteArray();
    }
}
 
源代码10 项目: ignite   文件: ClientConfigurationTest.java
/** Serialization/deserialization. */
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
    ClientConfiguration target = new ClientConfiguration()
        .setAddresses("127.0.0.1:10800", "127.0.0.1:10801")
        .setTimeout(123)
        .setBinaryConfiguration(new BinaryConfiguration()
            .setClassNames(Collections.singleton("Person"))
        )
        .setSslMode(SslMode.REQUIRED)
        .setSslClientCertificateKeyStorePath("client.jks")
        .setSslClientCertificateKeyStoreType("JKS")
        .setSslClientCertificateKeyStorePassword("123456")
        .setSslTrustCertificateKeyStorePath("trust.jks")
        .setSslTrustCertificateKeyStoreType("JKS")
        .setSslTrustCertificateKeyStorePassword("123456")
        .setSslKeyAlgorithm("SunX509");

    ByteArrayOutputStream outBytes = new ByteArrayOutputStream();

    ObjectOutput out = new ObjectOutputStream(outBytes);

    out.writeObject(target);
    out.flush();

    ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(outBytes.toByteArray()));

    Object desTarget = in.readObject();

    assertTrue(Comparers.equal(target, desTarget));
}
 
源代码11 项目: directory-ldap-api   文件: DefaultEntry.java
/**
 * This is the place where we serialize entries, and all theirs
 * elements.
 * <br>
 * The structure used to store the entry is the following :
 * <ul>
 *   <li>
 *     <b>[Dn]</b> : If it's null, stores an empty Dn
 *   </li>
 *   <li>
 *     <b>[attributes number]</b> : the number of attributes.
 *   </li>
 *   <li>
 *     <b>[attribute]*</b> : each attribute, if we have some
 *   </li>
 * </ul>
 *
 * {@inheritDoc}
 */
@Override
public void writeExternal( ObjectOutput out ) throws IOException
{
    // First, the Dn
    if ( dn == null )
    {
        // Write an empty Dn
        Dn.EMPTY_DN.writeExternal( out );
    }
    else
    {
        // Write the Dn
        dn.writeExternal( out );
    }

    // Then the attributes.
    // Store the attributes' nulber first
    out.writeInt( attributes.size() );

    // Iterate through the keys.
    for ( Attribute attribute : attributes.values() )
    {
        // Store the attribute
        attribute.writeExternal( out );
    }

    out.flush();
}
 
源代码12 项目: MyVirtualDirectory   文件: DefaultEntry.java
/**
 * This is the place where we serialize entries, and all theirs
 * elements.
 * <br/>
 * The structure used to store the entry is the following :
 * <ul>
 *   <li>
 *     <b>[Dn]</b> : If it's null, stores an empty Dn
 *   </li>
 *   <li>
 *     <b>[attributes number]</b> : the number of attributes.
 *   </li>
 *   <li>
 *     <b>[attribute]*</b> : each attribute, if we have some
 *   </li>
 * </ul>
 * 
 * {@inheritDoc}
 */
public void writeExternal( ObjectOutput out ) throws IOException
{
    // First, the Dn
    if ( dn == null )
    {
        // Write an empty Dn
        Dn.EMPTY_DN.writeExternal( out );
    }
    else
    {
        // Write the Dn
        dn.writeExternal( out );
    }

    // Then the attributes.
    // Store the attributes' nulber first
    out.writeInt( attributes.size() );

    // Iterate through the keys.
    for ( Attribute attribute : attributes.values() )
    {
        // Store the attribute
        attribute.writeExternal( out );
    }

    out.flush();
}
 
源代码13 项目: jdk1.8-source-analysis   文件: BitArray.java
public void writeExternal(ObjectOutput out) throws IOException {
    out.writeInt(_bitSize);
    out.writeInt(_mask);
    out.writeObject(_bits);
    out.flush();
}
 
源代码14 项目: mynlp   文件: CoreDictionaryImpl.java
@Override
public void writeExternal(ObjectOutput out) throws IOException {
    out.writeInt(totalFreq);
    trie.save(out);
    out.flush();
}
 
源代码15 项目: jdk8u60   文件: BitArray.java
public void writeExternal(ObjectOutput out) throws IOException {
    out.writeInt(_bitSize);
    out.writeInt(_mask);
    out.writeObject(_bits);
    out.flush();
}
 
源代码16 项目: openjdk-jdk9   文件: BitArray.java
public void writeExternal(ObjectOutput out) throws IOException {
    out.writeInt(_bitSize);
    out.writeInt(_mask);
    out.writeObject(_bits);
    out.flush();
}
 
源代码17 项目: openjdk-jdk8u   文件: BitArray.java
public void writeExternal(ObjectOutput out) throws IOException {
    out.writeInt(_bitSize);
    out.writeInt(_mask);
    out.writeObject(_bits);
    out.flush();
}
 
源代码18 项目: openjdk-8-source   文件: BitArray.java
public void writeExternal(ObjectOutput out) throws IOException {
    out.writeInt(_bitSize);
    out.writeInt(_mask);
    out.writeObject(_bits);
    out.flush();
}
 
源代码19 项目: directory-ldap-api   文件: Value.java
/**
 * {@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();
}
 
源代码20 项目: ignite   文件: ClientCacheConfigurationTest.java
/** Serialization/deserialization. */
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
    ClientCacheConfiguration target = new ClientCacheConfiguration().setName("Person")
        .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL)
        .setBackups(3)
        .setCacheMode(CacheMode.PARTITIONED)
        .setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC)
        .setEagerTtl(false)
        .setGroupName("FunctionalTest")
        .setDefaultLockTimeout(12345)
        .setPartitionLossPolicy(PartitionLossPolicy.READ_WRITE_ALL)
        .setReadFromBackup(true)
        .setRebalanceBatchSize(67890)
        .setRebalanceBatchesPrefetchCount(102938)
        .setRebalanceDelay(54321)
        .setRebalanceMode(CacheRebalanceMode.SYNC)
        .setRebalanceOrder(2)
        .setRebalanceThrottle(564738)
        .setRebalanceTimeout(142536)
        .setKeyConfiguration(new CacheKeyConfiguration("Employee", "orgId"))
        .setQueryEntities(new QueryEntity(int.class.getName(), "Employee")
            .setTableName("EMPLOYEE")
            .setFields(
                Stream.of(
                    new SimpleEntry<>("id", Integer.class.getName()),
                    new SimpleEntry<>("orgId", Integer.class.getName())
                ).collect(Collectors.toMap(
                    SimpleEntry::getKey, SimpleEntry::getValue, (a, b) -> a, LinkedHashMap::new
                ))
            )
            .setKeyFields(Collections.singleton("id"))
            .setNotNullFields(Collections.singleton("id"))
            .setDefaultFieldValues(Collections.singletonMap("id", 0))
            .setIndexes(Collections.singletonList(new QueryIndex("id", true, "IDX_EMPLOYEE_ID")))
            .setAliases(Stream.of("id", "orgId").collect(Collectors.toMap(f -> f, String::toUpperCase)))
        );

    ByteArrayOutputStream outBytes = new ByteArrayOutputStream();

    ObjectOutput out = new ObjectOutputStream(outBytes);

    out.writeObject(target);
    out.flush();

    ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(outBytes.toByteArray()));

    Object desTarget = in.readObject();

    assertTrue(Comparers.equal(target, desTarget));
}