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


Java ObjectOutputStream.writeByte方法代碼示例

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


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

示例1: encodeResponse

import java.io.ObjectOutputStream; //導入方法依賴的package包/類
private void encodeResponse(ResponseMessage res, ObjectOutputStream out) throws IOException{
	if(res.isHeartBeat()){
           out.writeObject(null);
       } else {
           // encode response data or error message.
           Throwable th = res.getException();
           if (th == null) {
               Object ret = res.getResponse();
               if (ret == null) {
                   out.writeByte(DubboAdapter.RESPONSE_NULL_VALUE);
               } else {
                   out.writeByte(DubboAdapter.RESPONSE_VALUE);
                   writeObject(ret, out);
               }
           } else {
               out.writeByte(DubboAdapter.RESPONSE_WITH_EXCEPTION);
               writeObject(th, out);
           }
       }
}
 
開發者ID:tiglabs,項目名稱:jsf-sdk,代碼行數:21,代碼來源:JavaEncoder.java

示例2: doReps

import java.io.ObjectOutputStream; //導入方法依賴的package包/類
/**
 * Run benchmark for given number of batches, with given number of cycles
 * for each batch.
 */
void doReps(ObjectOutputStream oout, ObjectInputStream oin,
            StreamBuffer sbuf, int nbatches, int ncycles)
    throws Exception
{
    for (int i = 0; i < nbatches; i++) {
        sbuf.reset();
        for (int j = 0; j < ncycles; j++) {
            oout.writeByte(0);
        }
        oout.flush();
        for (int j = 0; j < ncycles; j++) {
            oin.readByte();
        }
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:20,代碼來源:Bytes.java

示例3: serializeMainFile

import java.io.ObjectOutputStream; //導入方法依賴的package包/類
@Override
public void serializeMainFile(ObjectOutputStream objectOutputStream) throws IOException {
    objectOutputStream.writeInt(data.length);
    objectOutputStream.writeLong(nextIDNeverYetAssigned);
    objectOutputStream.writeByte(nextBucketOffset);
    objectOutputStream.writeInt(nextBucketId);
    objectOutputStream.writeInt(nextPartitionId);
    objectOutputStream.writeInt(recycledIdsSize);
    objectOutputStream.writeObject(recycledIds);
}
 
開發者ID:graphflow,項目名稱:graphflow,代碼行數:11,代碼來源:EdgeStore.java

示例4: writeObject

import java.io.ObjectOutputStream; //導入方法依賴的package包/類
private void writeObject(Object obj, ObjectOutputStream oos) throws IOException {
	if( obj == null ) {
		oos.writeByte(0);
	} else {
		oos.writeByte(1);
		oos.writeObject(obj);
	}
}
 
開發者ID:tiglabs,項目名稱:jsf-sdk,代碼行數:9,代碼來源:JavaEncoder.java

示例5: writeObject

import java.io.ObjectOutputStream; //導入方法依賴的package包/類
private void writeObject(ObjectOutputStream out) throws IOException {
    out.writeBoolean(z);
    out.writeByte(b);
    out.writeChar(c);
    out.writeShort(s);
    out.writeInt(i);
    out.writeFloat(f);
    out.writeLong(j);
    out.writeDouble(d);
    out.writeObject(str);
    out.writeObject(parent);
    out.writeObject(left);
    out.writeObject(right);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:15,代碼來源:CustomObjTrees.java

示例6: writeObject

import java.io.ObjectOutputStream; //導入方法依賴的package包/類
void writeObject(ObjectOutputStream out) throws IOException {
    out.writeInt(mode);
    for (int i = 0; i < generalNumbers.length; i++) {
        out.writeLong(generalNumbers[i]);
    }

    if (mode == CommonConstants.MODE_THREADS_SAMPLING) {
        out.writeInt(nThreads);
        out.writeInt(nThreadStates);
        for (int i = 0; i < nThreads; i++) {
            out.writeInt(threadIds[i]);
        }
        for (int i = 0; i < nThreadStates; i++) {
            out.writeLong(stateTimestamps[i]);
        }
        int len = nThreads * nThreadStates;
        out.write(threadStates, 0, len);
    } else if (mode == CommonConstants.MODE_THREADS_EXACT) {
        out.writeInt(exactThreadStates.length);
        for (int i = 0; i < exactThreadIds.length; i++) {
            out.writeInt(exactThreadIds[i]);
            out.writeByte(exactThreadStates[i]);
            out.writeLong(exactTimeStamps[i]);
        }
    }

    if (nNewThreads == 0) {
        out.writeInt(0);
    } else {
        out.writeInt(nNewThreads);

        for (int i = 0; i < nNewThreads; i++) {
            out.writeInt(newThreadIds[i]);
            out.writeUTF(newThreadNames[i]);
            out.writeUTF(newThreadClassNames[i]);
        }
    }

    out.writeInt(gcStarts.length);

    for (int i = 0; i < gcStarts.length; i++) {
        out.writeLong(gcStarts[i]);
    }

    out.writeInt(gcFinishs.length);

    for (int i = 0; i < gcFinishs.length; i++) {
        out.writeLong(gcFinishs[i]);
    }

    out.writeInt(serverState);
    out.writeInt(serverProgress);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:54,代碼來源:MonitoredNumbersResponse.java

示例7: doCall

import java.io.ObjectOutputStream; //導入方法依賴的package包/類
private void doCall ( DataInputStream in, DataOutputStream out, Object payload ) throws Exception {
    ObjectInputStream ois = new ObjectInputStream(in) {

        @Override
        protected Class<?> resolveClass ( ObjectStreamClass desc ) throws IOException, ClassNotFoundException {
            if ( "[Ljava.rmi.server.ObjID;".equals(desc.getName())) {
                return ObjID[].class;
            } else if ("java.rmi.server.ObjID".equals(desc.getName())) {
                return ObjID.class;
            } else if ( "java.rmi.server.UID".equals(desc.getName())) {
                return UID.class;
            }
            throw new IOException("Not allowed to read object");
        }
    };

    ObjID read;
    try {
        read = ObjID.read(ois);
    }
    catch ( java.io.IOException e ) {
        throw new MarshalException("unable to read objID", e);
    }


    if ( read.hashCode() == 2 ) {
        ois.readInt(); // method
        ois.readLong(); // hash
        System.err.println("Is DGC call for " + Arrays.toString((ObjID[])ois.readObject()));
    }

    System.err.println("Sending return with payload for obj " + read);

    out.writeByte(TransportConstants.Return);// transport op
    ObjectOutputStream oos = new JRMPClient.MarshalOutputStream(out, this.classpathUrl);

    oos.writeByte(TransportConstants.ExceptionalReturn);
    new UID().write(oos);

    BadAttributeValueExpException ex = new BadAttributeValueExpException(null);
    Reflections.setFieldValue(ex, "val", payload);
    oos.writeObject(ex);

    oos.flush();
    out.flush();

    this.hadConnection = true;
    synchronized ( this.waitLock ) {
        this.waitLock.notifyAll();
    }
}
 
開發者ID:hucheat,項目名稱:APacheSynapseSimplePOC,代碼行數:52,代碼來源:JRMPListener.java

示例8: writeObject

import java.io.ObjectOutputStream; //導入方法依賴的package包/類
private void writeObject( ObjectOutputStream out ) throws IOException {

		bucketLocker.lockAllBuckets();

		final Serialization serialization = new Serialization();

		// Write bucket values
		out.writeInt( fpBits );
		out.writeInt( buckets.getEntriesPerBucket() );
		out.writeLong( buckets.getBucketCount() );
		out.writeBoolean( buckets.isCountingDisabled() );
		out.writeLong( buckets.getInsertedCount() );
		buckets.writeMemory( out );

		// Write kicked values
		out.writeInt( kickedValues.getKickedFingerprint() );
		out.writeLong( kickedValues.getKickedBucket() );

		// Write bucket locker values
		out.writeInt( bucketLocker.getConcurrency() );

		// Write swapper values
		out.writeInt( swapper.getMaxKicks() );
		// Write random int provider
		final byte randomIntType = serialization.getRandomIntType( swapper.getRandomInt() );
		out.writeByte( randomIntType );
		if ( serialization.isCustomType( randomIntType ) ) {
			out.writeObject( swapper.getRandomInt() );
		}

		// Write string encoder
		final byte stringEncoderType = serialization.getStringEncoderType( stringEncoder );
		out.writeByte( stringEncoderType );
		if ( serialization.isCustomType( stringEncoderType ) ) {
			out.writeObject( stringEncoder );
		}

		// Write bucket hasher
		final byte bucketHasherType = serialization.getBucketHasherType( bucketHasher );
		out.writeByte( bucketHasherType );
		if ( serialization.isCustomType( bucketHasherType ) ) {
			out.writeObject( bucketHasher );
		} else {
			out.writeInt( bucketHasher.getSeed() );
		}

		// Write fingerprint hasher
		final byte fpHasherType = serialization.getFingerprintHasherType( fpHasher );
		out.writeByte( fpHasherType );
		if ( serialization.isCustomType( fpHasherType ) ) {
			out.writeObject( fpHasher );
		}

		bucketLocker.unlockAllBuckets();
	}
 
開發者ID:cinnom,項目名稱:nano-cuckoo,代碼行數:56,代碼來源:NanoCuckooFilter.java

示例9: doCall

import java.io.ObjectOutputStream; //導入方法依賴的package包/類
private void doCall ( DataInputStream in, DataOutputStream out, Object payload ) throws Exception {
    ObjectInputStream ois = new ObjectInputStream(in) {

        @Override
        protected Class<?> resolveClass ( ObjectStreamClass desc ) throws IOException, ClassNotFoundException {
            if ( "[Ljava.rmi.server.ObjID;".equals(desc.getName())) {
                return ObjID[].class;
            } else if ("java.rmi.server.ObjID".equals(desc.getName())) {
                return ObjID.class;
            } else if ( "java.rmi.server.UID".equals(desc.getName())) {
                return UID.class;
            }
            throw new IOException("Not allowed to read object");
        }
    };

    ObjID read;
    try {
        read = ObjID.read(ois);
    }
    catch ( java.io.IOException e ) {
        throw new MarshalException("unable to read objID", e);
    }

    
    if ( read.hashCode() == 2 ) {
        ois.readInt(); // method
        ois.readLong(); // hash
        System.err.println("Is DGC call for " + Arrays.toString((ObjID[])ois.readObject()));
    }
    
    System.err.println("Sending return with payload for obj " + read);

    out.writeByte(TransportConstants.Return);// transport op
    ObjectOutputStream oos = new JRMPClient.MarshalOutputStream(out, this.classpathUrl);

    oos.writeByte(TransportConstants.ExceptionalReturn);
    new UID().write(oos);

    BadAttributeValueExpException ex = new BadAttributeValueExpException(null);
    Reflections.setFieldValue(ex, "val", payload);
    oos.writeObject(ex);

    oos.flush();
    out.flush();

    this.hadConnection = true;
    synchronized ( this.waitLock ) {
        this.waitLock.notifyAll();
    }
}
 
開發者ID:pimps,項目名稱:ysoserial-modified,代碼行數:52,代碼來源:JRMPListener.java

示例10: exportType

import java.io.ObjectOutputStream; //導入方法依賴的package包/類
private void exportType(TypeDef te, ObjectOutputStream out)throws IOException{
    out.writeUTF(te.getName());
    out.writeBoolean(te.classExplicit());
    
    //escludere membri override
    Membro[] i=te.getMembri();
    int l=0;
    for(Membro m:i){
        if(!m.override)
            l++;
    }
    out.writeInt(l);
    for(Membro mem:i){
        if(mem.override)
            continue;
        int perms=0;
        //non ci sono override
        if(mem.gpacked)
            perms=1;
        else if(mem.ghost)
            perms=2;
        perms*=3;
        if(mem.shadow)
            perms+=1;
        if(mem.read)
            perms+=2;
        out.writeByte(perms & 0xFF);
        out.writeObject(mem.getType());
        out.writeUTF(mem.getIdent());
        out.writeInt(mem.params.length);
        for(TypeName t:mem.params)
            out.writeObject(t);
        if(mem.packed==null)
            out.writeBoolean(false);
        else{
            out.writeBoolean(true);
            //Sicuramente NumDich
            out.writeLong(((NumDich)mem.packed).getNum());
        }
    }
    if(te.extend()!=null){
        out.writeBoolean(true);
        out.writeObject(te.extend());
    }
    else
        out.writeBoolean(false);
}
 
開發者ID:Loara,項目名稱:Meucci,代碼行數:48,代碼來源:ModLoader.java


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