Java Code Examples for java.io.ObjectOutput

The following are top voted examples for showing how to use java.io.ObjectOutput. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: HCFCore   File: TLongArrayList.java   View source code 7 votes vote down vote up
public void writeExternal( ObjectOutput out ) throws IOException {
	// VERSION
	out.writeByte( 0 );

	// POSITION
	out.writeInt( _pos );

	// NO_ENTRY_VALUE
	out.writeLong( no_entry_value );

	// ENTRIES
	int len = _data.length;
	out.writeInt( len );
	for( int i = 0; i < len; i++ ) {
		out.writeLong( _data[ i ] );
	}
}
 
Example 2
Project: HCFCore   File: TIntHashSet.java   View source code 6 votes vote down vote up
/** {@inheritDoc} */
public void writeExternal( ObjectOutput out ) throws IOException {

	// VERSION
	out.writeByte( 1 );

	// SUPER
	super.writeExternal( out );

	// NUMBER OF ENTRIES
	out.writeInt( _size );

    // LOAD FACTOR -- Added version 1
    out.writeFloat( _loadFactor );

    // NO ENTRY VALUE -- Added version 1
    out.writeInt( no_entry_value );

	// ENTRIES
    for ( int i = _states.length; i-- > 0; ) {
        if ( _states[i] == FULL ) {
            out.writeInt( _set[i] );
        }
    }
}
 
Example 3
Project: openjdk-jdk10   File: StreamRemoteCall.java   View source code 6 votes vote down vote up
/**
 * Returns an output stream (may put out header information
 * relating to the success of the call).
 * @param success If true, indicates normal return, else indicates
 * exceptional return.
 * @exception StreamCorruptedException If result stream previously
 * acquired
 * @exception IOException For any other problem with I/O.
 */
public ObjectOutput getResultStream(boolean success) throws IOException {
    /* make sure result code only marshaled once. */
    if (resultStarted)
        throw new StreamCorruptedException("result already in progress");
    else
        resultStarted = true;

    // write out return header
    // return header, part 1 (read by Transport)
    DataOutputStream wr = new DataOutputStream(conn.getOutputStream());
    wr.writeByte(TransportConstants.Return);// transport op
    getOutputStream(true);  // creates a MarshalOutputStream
    // return header, part 2 (read by client-side RemoteCall)
    if (success)            //
        out.writeByte(TransportConstants.NormalReturn);
    else
        out.writeByte(TransportConstants.ExceptionalReturn);
    out.writeID();          // write id for gcAck
    return out;
}
 
Example 4
Project: parabuild-ci   File: ComparableObjectSeriesTests.java   View source code 6 votes vote down vote up
/**
 * Serialize an instance, restore it, and check for equality.
 */
public void testSerialization() {
    MyComparableObjectSeries s1 = new MyComparableObjectSeries("A");
    s1.add(new Integer(1), "ABC");
    MyComparableObjectSeries s2 = null;
    try {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        ObjectOutput out = new ObjectOutputStream(buffer);
        out.writeObject(s1);
        out.close();

        ObjectInput in = new ObjectInputStream(
                new ByteArrayInputStream(buffer.toByteArray()));
        s2 = (MyComparableObjectSeries) in.readObject();
        in.close();
    }
    catch (Exception e) {
        e.printStackTrace();
    }
    assertEquals(s1, s2);
}
 
Example 5
Project: parabuild-ci   File: VectorRendererTests.java   View source code 6 votes vote down vote up
/**
 * Serialize an instance, restore it, and check for equality.
 */
public void testSerialization() {
    VectorRenderer r1 = new VectorRenderer();
    VectorRenderer r2 = null;
    try {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        ObjectOutput out = new ObjectOutputStream(buffer);
        out.writeObject(r1);
        out.close();

        ObjectInput in = new ObjectInputStream(
                new ByteArrayInputStream(buffer.toByteArray()));
        r2 = (VectorRenderer) in.readObject();
        in.close();
    }
    catch (Exception e) {
        e.printStackTrace();
    }
    assertEquals(r1, r2);
}
 
Example 6
Project: xcc   File: TShortArrayList.java   View source code 6 votes vote down vote up
public void writeExternal( ObjectOutput out ) throws IOException {
	// VERSION
	out.writeByte( 0 );

	// POSITION
	out.writeInt( _pos );

	// NO_ENTRY_VALUE
	out.writeShort( no_entry_value );

	// ENTRIES
	int len = _data.length;
	out.writeInt( len );
	for( int i = 0; i < len; i++ ) {
		out.writeShort( _data[ i ] );
	}
}
 
Example 7
Project: jaer   File: RecentFiles.java   View source code 6 votes vote down vote up
void putPrefs(){
    try {
        // Serialize to a byte array
        ByteArrayOutputStream bos = new ByteArrayOutputStream() ;
        ObjectOutput out = new ObjectOutputStream(bos) ;
        out.writeObject(fileList);
        out.close();
        
        // Get the bytes of the serialized object
        byte[] buf = bos.toByteArray();
        prefs.putByteArray("recentFiles", buf);
    } catch (IOException e) {
        e.printStackTrace();
    }catch(IllegalArgumentException e2){
        log.warning("RecentFiles tried to store too many files in Preferences, fileList has "+fileList.size()+" files");
    }
    
}
 
Example 8
Project: parabuild-ci   File: SymbolicAxisTests.java   View source code 6 votes vote down vote up
/**
 * Serialize an instance, restore it, and check for equality.
 */
public void testSerialization() {

    String[] tickLabels = new String[] {"One", "Two", "Three"};
    SymbolicAxis a1 = new SymbolicAxis("Test Axis", tickLabels);
    SymbolicAxis a2 = null;

    try {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        ObjectOutput out = new ObjectOutputStream(buffer);
        out.writeObject(a1);
        out.close();

        ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
        a2 = (SymbolicAxis) in.readObject();
        in.close();
    }
    catch (Exception e) {
        System.out.println(e.toString());
    }
    assertEquals(a1, a2);

}
 
Example 9
Project: xcc   File: TIntArrayList.java   View source code 6 votes vote down vote up
public void writeExternal( ObjectOutput out ) throws IOException {
	// VERSION
	out.writeByte( 0 );

	// POSITION
	out.writeInt( _pos );

	// NO_ENTRY_VALUE
	out.writeInt( no_entry_value );

	// ENTRIES
	int len = _data.length;
	out.writeInt( len );
	for( int i = 0; i < len; i++ ) {
		out.writeInt( _data[ i ] );
	}
}
 
Example 10
Project: xcc   File: TFloatArrayList.java   View source code 6 votes vote down vote up
public void writeExternal( ObjectOutput out ) throws IOException {
	// VERSION
	out.writeByte( 0 );

	// POSITION
	out.writeInt( _pos );

	// NO_ENTRY_VALUE
	out.writeFloat( no_entry_value );

	// ENTRIES
	int len = _data.length;
	out.writeInt( len );
	for( int i = 0; i < len; i++ ) {
		out.writeFloat( _data[ i ] );
	}
}
 
Example 11
Project: hashsdn-controller   File: MutableCompositeModification.java   View source code 6 votes vote down vote up
@Override
public void writeExternal(ObjectOutput out) throws IOException {
    super.writeExternal(out);

    out.writeInt(modifications.size());

    if (modifications.size() > 1) {
        SerializationUtils.REUSABLE_WRITER_TL.set(NormalizedNodeInputOutput.newDataOutput(out));
    }

    try {
        for (Modification mod: modifications) {
            out.writeByte(mod.getType());
            mod.writeExternal(out);
        }
    } finally {
        SerializationUtils.REUSABLE_WRITER_TL.remove();
    }
}
 
Example 12
Project: xcc   File: TShortHashSet.java   View source code 6 votes vote down vote up
/** {@inheritDoc} */
public void writeExternal( ObjectOutput out ) throws IOException {

	// VERSION
	out.writeByte( 1 );

	// SUPER
	super.writeExternal( out );

	// NUMBER OF ENTRIES
	out.writeInt( _size );

    // LOAD FACTOR -- Added version 1
    out.writeFloat( _loadFactor );

    // NO ENTRY VALUE -- Added version 1
    out.writeShort( no_entry_value );

	// ENTRIES
    for ( int i = _states.length; i-- > 0; ) {
        if ( _states[i] == FULL ) {
            out.writeShort( _set[i] );
        }
    }
}
 
Example 13
Project: xcc   File: TLongHashSet.java   View source code 6 votes vote down vote up
/** {@inheritDoc} */
public void writeExternal( ObjectOutput out ) throws IOException {

	// VERSION
	out.writeByte( 1 );

	// SUPER
	super.writeExternal( out );

	// NUMBER OF ENTRIES
	out.writeInt( _size );

    // LOAD FACTOR -- Added version 1
    out.writeFloat( _loadFactor );

    // NO ENTRY VALUE -- Added version 1
    out.writeLong( no_entry_value );

	// ENTRIES
    for ( int i = _states.length; i-- > 0; ) {
        if ( _states[i] == FULL ) {
            out.writeLong( _set[i] );
        }
    }
}
 
Example 14
Project: parabuild-ci   File: IntervalCategoryLabelGeneratorTests.java   View source code 6 votes vote down vote up
/**
 * Serialize an instance, restore it, and check for equality.
 */
public void testSerialization() {

    IntervalCategoryLabelGenerator g1
        = new IntervalCategoryLabelGenerator("{3} - {4}", DateFormat.getInstance());
    IntervalCategoryLabelGenerator g2 = null;

    try {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        ObjectOutput out = new ObjectOutputStream(buffer);
        out.writeObject(g1);
        out.close();

        ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
        g2 = (IntervalCategoryLabelGenerator) in.readObject();
        in.close();
    }
    catch (Exception e) {
        System.out.println(e.toString());
    }
    assertEquals(g1, g2);

}
 
Example 15
Project: xcc   File: TCharHashSet.java   View source code 6 votes vote down vote up
/** {@inheritDoc} */
public void writeExternal( ObjectOutput out ) throws IOException {

	// VERSION
	out.writeByte( 1 );

	// SUPER
	super.writeExternal( out );

	// NUMBER OF ENTRIES
	out.writeInt( _size );

    // LOAD FACTOR -- Added version 1
    out.writeFloat( _loadFactor );

    // NO ENTRY VALUE -- Added version 1
    out.writeChar( no_entry_value );

	// ENTRIES
    for ( int i = _states.length; i-- > 0; ) {
        if ( _states[i] == FULL ) {
            out.writeChar( _set[i] );
        }
    }
}
 
Example 16
Project: xcc   File: TCharIntHash.java   View source code 5 votes vote down vote up
/** {@inheritDoc} */
public void writeExternal( ObjectOutput out ) throws IOException {
    // VERSION
	out.writeByte( 0 );

    // SUPER
	super.writeExternal( out );

	// NO_ENTRY_KEY
	out.writeChar( no_entry_key );

	// NO_ENTRY_VALUE
	out.writeInt( no_entry_value );
}
 
Example 17
Project: jdk8u-jdk   File: Ser.java   View source code 5 votes vote down vote up
private static void writeInternal(byte type, Object object, ObjectOutput out) throws IOException {
    out.writeByte(type);
    switch (type) {
        case CHRONO_TYPE:
            ((AbstractChronology) object).writeExternal(out);
            break;
        case CHRONO_LOCAL_DATE_TIME_TYPE:
            ((ChronoLocalDateTimeImpl<?>) object).writeExternal(out);
            break;
        case CHRONO_ZONE_DATE_TIME_TYPE:
            ((ChronoZonedDateTimeImpl<?>) object).writeExternal(out);
            break;
        case JAPANESE_DATE_TYPE:
            ((JapaneseDate) object).writeExternal(out);
            break;
        case JAPANESE_ERA_TYPE:
            ((JapaneseEra) object).writeExternal(out);
            break;
        case HIJRAH_DATE_TYPE:
            ((HijrahDate) object).writeExternal(out);
            break;
        case MINGUO_DATE_TYPE:
            ((MinguoDate) object).writeExternal(out);
            break;
        case THAIBUDDHIST_DATE_TYPE:
            ((ThaiBuddhistDate) object).writeExternal(out);
            break;
        case CHRONO_PERIOD_TYPE:
            ((ChronoPeriodImpl) object).writeExternal(out);
            break;
        default:
            throw new InvalidClassException("Unknown serialized type");
    }
}
 
Example 18
Project: brModelo   File: GerenciadorPartes.java   View source code 5 votes vote down vote up
public static boolean SaveData(GerenciadorPartes obj, String fileName) {
    try {
        FileOutputStream fo = new FileOutputStream(fileName);
        try (ObjectOutput out = new ObjectOutputStream(fo)) {
            out.writeObject(obj);
        }
        obj.setMudou(false);
        return true;
    } catch (IOException iOException) {
        util.BrLogger.Logger("ERROR_TEMPLATE_SAVELOAD", iOException.getMessage());
        return false;
    }
}
 
Example 19
Project: Higher-Cloud-Computing-Project   File: RegionProjection.java   View source code 5 votes vote down vote up
/** {@inheritDoc} */
@Override public void writeExternal(ObjectOutput out) throws IOException {
    out.writeInt(sampleIndexes.length);

    for (Integer sampleIndex : sampleIndexes)
        out.writeInt(sampleIndex);

    out.writeObject(data);
    out.writeInt(depth);
}
 
Example 20
Project: lams   File: ValueExpressionImpl.java   View source code 5 votes vote down vote up
public void writeExternal(ObjectOutput out) throws IOException {
    out.writeUTF(this.expr);
    out.writeUTF((this.expectedType != null) ? this.expectedType.getName()
            : "");
    out.writeObject(this.fnMapper);
    out.writeObject(this.varMapper);
}
 
Example 21
Project: HCFCore   File: TByteIntHash.java   View source code 5 votes vote down vote up
/** {@inheritDoc} */
public void writeExternal( ObjectOutput out ) throws IOException {
    // VERSION
	out.writeByte( 0 );

    // SUPER
	super.writeExternal( out );

	// NO_ENTRY_KEY
	out.writeByte( no_entry_key );

	// NO_ENTRY_VALUE
	out.writeInt( no_entry_value );
}
 
Example 22
Project: xcc   File: TFloatLongHash.java   View source code 5 votes vote down vote up
/** {@inheritDoc} */
public void writeExternal( ObjectOutput out ) throws IOException {
    // VERSION
	out.writeByte( 0 );

    // SUPER
	super.writeExternal( out );

	// NO_ENTRY_KEY
	out.writeFloat( no_entry_key );

	// NO_ENTRY_VALUE
	out.writeLong( no_entry_value );
}
 
Example 23
Project: xcc   File: TDoubleFloatHash.java   View source code 5 votes vote down vote up
/** {@inheritDoc} */
public void writeExternal( ObjectOutput out ) throws IOException {
    // VERSION
	out.writeByte( 0 );

    // SUPER
	super.writeExternal( out );

	// NO_ENTRY_KEY
	out.writeDouble( no_entry_key );

	// NO_ENTRY_VALUE
	out.writeFloat( no_entry_value );
}
 
Example 24
Project: HCFCore   File: TIntShortHash.java   View source code 5 votes vote down vote up
/** {@inheritDoc} */
public void writeExternal( ObjectOutput out ) throws IOException {
    // VERSION
	out.writeByte( 0 );

    // SUPER
	super.writeExternal( out );

	// NO_ENTRY_KEY
	out.writeInt( no_entry_key );

	// NO_ENTRY_VALUE
	out.writeShort( no_entry_value );
}
 
Example 25
Project: unitimes   File: XWaitListedSection.java   View source code 5 votes vote down vote up
@Override
public void writeExternal(ObjectOutput out) throws IOException {
	super.writeExternal(out);
	out.writeLong(iWaitListId == null ? -1l : iWaitListId);
	out.writeBoolean(iTimeStamp != null);
	if (iTimeStamp != null)
		out.writeLong(iTimeStamp.getTime());
	out.writeInt(iType.ordinal());
}
 
Example 26
Project: HCFCore   File: TCharArrayStack.java   View source code 5 votes vote down vote up
public void writeExternal( ObjectOutput out ) throws IOException {
	// VERSION
	out.writeByte( 0 );

	// LIST
	out.writeObject( _list );
}
 
Example 27
Project: xcc   File: TLongLongHash.java   View source code 5 votes vote down vote up
/** {@inheritDoc} */
public void writeExternal( ObjectOutput out ) throws IOException {
    // VERSION
	out.writeByte( 0 );

    // SUPER
	super.writeExternal( out );

	// NO_ENTRY_KEY
	out.writeLong( no_entry_key );

	// NO_ENTRY_VALUE
	out.writeLong( no_entry_value );
}
 
Example 28
Project: HCFCore   File: TCharDoubleHash.java   View source code 5 votes vote down vote up
/** {@inheritDoc} */
public void writeExternal( ObjectOutput out ) throws IOException {
    // VERSION
	out.writeByte( 0 );

    // SUPER
	super.writeExternal( out );

	// NO_ENTRY_KEY
	out.writeChar( no_entry_key );

	// NO_ENTRY_VALUE
	out.writeDouble( no_entry_value );
}
 
Example 29
Project: HCFCore   File: TByteCharHash.java   View source code 5 votes vote down vote up
/** {@inheritDoc} */
public void writeExternal( ObjectOutput out ) throws IOException {
    // VERSION
	out.writeByte( 0 );

    // SUPER
	super.writeExternal( out );

	// NO_ENTRY_KEY
	out.writeByte( no_entry_key );

	// NO_ENTRY_VALUE
	out.writeChar( no_entry_value );
}
 
Example 30
Project: hashsdn-controller   File: InstallSnapshotReply.java   View source code 5 votes vote down vote up
@Override
public void writeExternal(ObjectOutput out) throws IOException {
    out.writeLong(installSnapshotReply.getTerm());
    out.writeObject(installSnapshotReply.followerId);
    out.writeInt(installSnapshotReply.chunkIndex);
    out.writeBoolean(installSnapshotReply.success);
}
 
Example 31
Project: unitimes   File: XExpectations.java   View source code 5 votes vote down vote up
@Override
public void writeExternal(ObjectOutput out) throws IOException {
	out.writeLong(iOfferingId);
	out.writeInt(iExpectations == null ? 0 : iExpectations.size());
	if (iExpectations != null) {
		for (Map.Entry<Long, Double> entry: iExpectations.entrySet()) {
			out.writeLong(entry.getKey());
			out.writeDouble(entry.getValue());
		}
	}
}
 
Example 32
Project: incubator-netbeans   File: DeveloperHtmlBrowserComponent.java   View source code 5 votes vote down vote up
@Override
public void writeExternal (ObjectOutput out)
throws IOException {
    out.writeBoolean (bComp.isStatusLineVisible ());
    out.writeBoolean (bComp.isToolbarVisible ());
    out.writeObject (bComp.getDocumentURL ());
}
 
Example 33
Project: xcc   File: TLongDoubleHash.java   View source code 5 votes vote down vote up
/** {@inheritDoc} */
public void writeExternal( ObjectOutput out ) throws IOException {
    // VERSION
	out.writeByte( 0 );

    // SUPER
	super.writeExternal( out );

	// NO_ENTRY_KEY
	out.writeLong( no_entry_key );

	// NO_ENTRY_VALUE
	out.writeDouble( no_entry_value );
}
 
Example 34
Project: HCFCore   File: TIntLinkedList.java   View source code 5 votes vote down vote up
/** {@inheritDoc} */
public void writeExternal(ObjectOutput out) throws IOException {
    // VERSION
    out.writeByte(0);

    // NO_ENTRY_VALUE
    out.writeInt(no_entry_value);

    // ENTRIES
    out.writeInt(size);
    for (TIntIterator iterator = iterator(); iterator.hasNext();) {
        int next = iterator.next();
        out.writeInt(next);
    }
}
 
Example 35
Project: VASSAL-src   File: IOUtils.java   View source code 5 votes vote down vote up
/**
 * Close an {@link ObjectOutput} unconditionally. Equivalent to
 * calling <code>o.close()</code> when <code>o</code> is nonnull.
 * {@link IOException}s are swallowed, as there is generally
 * nothing that can be done about exceptions on closing.
 *
 * @param o a (possibly <code>null</code>) <code>ObjectOutput</code>
 */
public static void closeQuietly(ObjectOutput o) {
  if (o == null) return;

  try {
    o.close();
  }
  catch (IOException e) {
    // ignore
  }
}
 
Example 36
Project: xcc   File: TFloatListDecorator.java   View source code 5 votes vote down vote up
public void writeExternal( ObjectOutput out ) throws IOException {
    // VERSION
    out.writeByte(0);

    // LIST
    out.writeObject( list );
}
 
Example 37
Project: fitnotifications   File: MeasureUnit.java   View source code 5 votes vote down vote up
@Override
public void writeExternal(ObjectOutput out) throws IOException {
    out.writeByte(0); // version
    out.writeUTF(type);
    out.writeUTF(subType);
    out.writeShort(0); // allow for more data.
}
 
Example 38
Project: xcc   File: TCharByteHash.java   View source code 5 votes vote down vote up
/** {@inheritDoc} */
public void writeExternal( ObjectOutput out ) throws IOException {
    // VERSION
	out.writeByte( 0 );

    // SUPER
	super.writeExternal( out );

	// NO_ENTRY_KEY
	out.writeChar( no_entry_key );

	// NO_ENTRY_VALUE
	out.writeByte( no_entry_value );
}
 
Example 39
Project: HCFCore   File: TDoubleArrayStack.java   View source code 5 votes vote down vote up
public void writeExternal( ObjectOutput out ) throws IOException {
	// VERSION
	out.writeByte( 0 );

	// LIST
	out.writeObject( _list );
}
 
Example 40
Project: xcc   File: TDoubleDoubleHash.java   View source code 5 votes vote down vote up
/** {@inheritDoc} */
public void writeExternal( ObjectOutput out ) throws IOException {
    // VERSION
	out.writeByte( 0 );

    // SUPER
	super.writeExternal( out );

	// NO_ENTRY_KEY
	out.writeDouble( no_entry_key );

	// NO_ENTRY_VALUE
	out.writeDouble( no_entry_value );
}