本文整理汇总了Java中java.io.ObjectOutput.flush方法的典型用法代码示例。如果您正苦于以下问题:Java ObjectOutput.flush方法的具体用法?Java ObjectOutput.flush怎么用?Java ObjectOutput.flush使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.io.ObjectOutput
的用法示例。
在下文中一共展示了ObjectOutput.flush方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeExternal
import java.io.ObjectOutput; //导入方法依赖的package包/类
/**
* @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: 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包/类
/**
* {@inheritDoc}
*/
@Override
public void writeExternal( ObjectOutput out ) throws IOException
{
if ( upName == null )
{
String message = "Cannot serialize a 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();
}
示例4: toByteArray
import java.io.ObjectOutput; //导入方法依赖的package包/类
public byte[] toByteArray() throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(baos);
out.writeObject(this);
out.flush();
return baos.toByteArray();
}
示例5: writeExternal
import java.io.ObjectOutput; //导入方法依赖的package包/类
/**
* 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();
}
示例6: writeExternal
import java.io.ObjectOutput; //导入方法依赖的package包/类
/**
* This is the place where we serialize attributes, and all theirs
* elements.
*
* {@inheritDoc}
*/
@Override
public void writeExternal( ObjectOutput out ) throws IOException
{
// Write the UPId
out.writeUTF( upId );
// Write the ID
out.writeUTF( id );
// Write the HR flag, if not null
if ( isHR != null )
{
out.writeBoolean( true );
out.writeBoolean( isHR );
}
else
{
out.writeBoolean( false );
}
// Write the number of values
out.writeInt( size() );
if ( size() > 0 )
{
// Write each value
for ( Value value : values )
{
// Write the value
value.writeExternal( out );
}
}
out.flush();
}
示例7: serialize
import java.io.ObjectOutput; //导入方法依赖的package包/类
@Override
public byte[] serialize(Object obj) throws TccException {
try (ByteArrayOutputStream arrayOutputStream = new ByteArrayOutputStream()) {
ObjectOutput objectOutput = new ObjectOutputStream(arrayOutputStream);
objectOutput.writeObject(obj);
objectOutput.flush();
objectOutput.close();
return arrayOutputStream.toByteArray();
} catch (IOException e) {
throw new TccException("JAVA serialize error " + e.getMessage());
}
}
示例8: writeExternal
import java.io.ObjectOutput; //导入方法依赖的package包/类
@Override
public void writeExternal(ObjectOutput out) throws IOException {
out.writeObject(color.getRed());
out.writeObject(color.getGreen());
out.writeObject(color.getBlue());
out.writeObject(color.getOpacity());
out.flush();
}
示例9: 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();
}
示例10: writeExternal
import java.io.ObjectOutput; //导入方法依赖的package包/类
public void writeExternal(ObjectOutput out) throws IOException {
out.writeInt(_bitSize);
out.writeInt(_mask);
out.writeObject(_bits);
out.flush();
}
示例11: writeExternal
import java.io.ObjectOutput; //导入方法依赖的package包/类
/**
* A Rdn is composed of on to many Avas (AttributeType And Value).
* We should write all those Avas sequencially, following the
* structure :
* <ul>
* <li>
* <b>parentId</b> The parent entry's Id
* </li>
* <li>
* <b>nbAvas</b> The number of Avas to write. Can't be 0.
* </li>
* <li>
* <b>upName</b> The User provided Rdn
* </li>
* <li>
* <b>Avas</b>
* </li>
* </ul>
* <br>
* For each Ava :
* <ul>
* <li>
* <b>start</b> The position of this Ava in the upName string
* </li>
* <li>
* <b>length</b> The Ava user provided length
* </li>
* <li>
* <b>Call the Ava write method</b> The Ava itself
* </li>
* </ul>
*
* @see Externalizable#readExternal(ObjectInput)
* @param out The stream into which the serialized Rdn will be put
* @throws IOException If the stream can't be written
*/
@Override
public void writeExternal( ObjectOutput out ) throws IOException
{
out.writeInt( nbAvas );
out.writeUTF( upName );
switch ( nbAvas )
{
case 0:
break;
case 1:
ava.writeExternal( out );
break;
default:
for ( Ava localAva : avas )
{
localAva.writeExternal( out );
}
break;
}
out.writeInt( h );
out.flush();
}