當前位置: 首頁>>代碼示例>>Java>>正文


Java ObjectOutput類代碼示例

本文整理匯總了Java中java.io.ObjectOutput的典型用法代碼示例。如果您正苦於以下問題:Java ObjectOutput類的具體用法?Java ObjectOutput怎麽用?Java ObjectOutput使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ObjectOutput類屬於java.io包,在下文中一共展示了ObjectOutput類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: writeExternal

import java.io.ObjectOutput; //導入依賴的package包/類
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 ] );
	}
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:18,代碼來源:TLongArrayList.java

示例2: writeExternal

import java.io.ObjectOutput; //導入依賴的package包/類
/** {@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] );
        }
    }
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:26,代碼來源:TIntHashSet.java

示例3: getResultStream

import java.io.ObjectOutput; //導入依賴的package包/類
/**
 * 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;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:30,代碼來源:StreamRemoteCall.java

示例4: testSerialization

import java.io.ObjectOutput; //導入依賴的package包/類
/**
 * 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);
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:24,代碼來源:ComparableObjectSeriesTests.java

示例5: testSerialization

import java.io.ObjectOutput; //導入依賴的package包/類
/**
 * 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);
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:23,代碼來源:VectorRendererTests.java

示例6: writeExternal

import java.io.ObjectOutput; //導入依賴的package包/類
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 ] );
	}
}
 
開發者ID:JianpingZeng,項目名稱:xcc,代碼行數:18,代碼來源:TShortArrayList.java

示例7: putPrefs

import java.io.ObjectOutput; //導入依賴的package包/類
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");
    }
    
}
 
開發者ID:SensorsINI,項目名稱:jaer,代碼行數:19,代碼來源:RecentFiles.java

示例8: testSerialization

import java.io.ObjectOutput; //導入依賴的package包/類
/**
 * 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);

}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:26,代碼來源:SymbolicAxisTests.java

示例9: writeExternal

import java.io.ObjectOutput; //導入依賴的package包/類
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 ] );
	}
}
 
開發者ID:JianpingZeng,項目名稱:xcc,代碼行數:18,代碼來源:TIntArrayList.java

示例10: writeExternal

import java.io.ObjectOutput; //導入依賴的package包/類
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 ] );
	}
}
 
開發者ID:JianpingZeng,項目名稱:xcc,代碼行數:18,代碼來源:TFloatArrayList.java

示例11: writeExternal

import java.io.ObjectOutput; //導入依賴的package包/類
@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();
    }
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:20,代碼來源:MutableCompositeModification.java

示例12: writeExternal

import java.io.ObjectOutput; //導入依賴的package包/類
/** {@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] );
        }
    }
}
 
開發者ID:JianpingZeng,項目名稱:xcc,代碼行數:26,代碼來源:TShortHashSet.java

示例13: writeExternal

import java.io.ObjectOutput; //導入依賴的package包/類
/** {@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] );
        }
    }
}
 
開發者ID:JianpingZeng,項目名稱:xcc,代碼行數:26,代碼來源:TLongHashSet.java

示例14: testSerialization

import java.io.ObjectOutput; //導入依賴的package包/類
/**
 * 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);

}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:26,代碼來源:IntervalCategoryLabelGeneratorTests.java

示例15: writeExternal

import java.io.ObjectOutput; //導入依賴的package包/類
/** {@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] );
        }
    }
}
 
開發者ID:JianpingZeng,項目名稱:xcc,代碼行數:26,代碼來源:TCharHashSet.java


注:本文中的java.io.ObjectOutput類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。