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


Java ObjectOutputStream.writeUTF方法代碼示例

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


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

示例1: writeObject

import java.io.ObjectOutputStream; //導入方法依賴的package包/類
void writeObject(ObjectOutputStream out) throws IOException {
    out.writeInt(bufSize);
    out.writeBoolean(buffer != null);
    if (buffer != null) {
        Deflater compressor = new Deflater();
        // for small buffers, the compressed size can be somewhat larger than the original  
        byte[] compressedBytes = new byte[bufSize + 32]; 
        int compressedSize;
        
        compressor.setInput(buffer,startPos,bufSize);
        compressor.finish();
        compressedSize = compressor.deflate(compressedBytes);
        out.writeInt(compressedSize);
        out.write(compressedBytes,0,compressedSize);
    } else {
        out.writeUTF(eventBufferFileName);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:19,代碼來源:EventBufferDumpedCommand.java

示例2: writeObject

import java.io.ObjectOutputStream; //導入方法依賴的package包/類
void writeObject(ObjectOutputStream out) throws IOException {
    if (classes == null) {
        out.writeInt(0);

        return;
    }

    int nClasses = classes.length;
    out.writeInt(nClasses);

    for (int i = 0; i < nClasses; i++) {
        out.writeUTF(classes[i]);
        out.writeInt(classLoaderIds[i]);
    }

    classes = null;
    classLoaderIds = null;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:19,代碼來源:GetClassFileBytesCommand.java

示例3: writeObject

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

    for (int i = 0; i < 3; i++) {
        out.writeInt(thisAndParentLoaderData[i]);
    }

    if (classFileBytes != null) {
        out.writeInt(classFileBytes.length);
        out.write(classFileBytes);
        classFileBytes = null;
    } else {
        out.writeInt(0);
    }

    out.writeBoolean(threadInCallGraph);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:18,代碼來源:ClassLoadedCommand.java

示例4: serialize

import java.io.ObjectOutputStream; //導入方法依賴的package包/類
/**
 * Custom serialization hook used during Session serialization.
 *
 * @param oos The stream to which to write the factory
 * @throws IOException Indicates problems writing out the serial data stream
 */
void serialize(ObjectOutputStream oos) throws IOException {
	oos.writeUTF( uuid );
	oos.writeBoolean( name != null );
	if ( name != null ) {
		oos.writeUTF( name );
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:14,代碼來源:SessionFactoryImpl.java

示例5: writeObject

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

    out.writeLong(mCoordinates != null ? mCoordinates.first : -1);
    out.writeLong(mCoordinates != null ? mCoordinates.second : -1);

    out.writeUTF(mLocation != null ? mLocation.getProvider() : null);
    out.writeDouble(mLocation != null ? mLocation.getLatitude() : -1);
    out.writeDouble(mLocation != null ? mLocation.getLongitude() : -1);
    out.writeFloat(mLocation != null ? mLocation.getAccuracy() : -1);
    out.writeDouble(mLocation != null ? mLocation.getAltitude() : -1);
}
 
開發者ID:suomenriistakeskus,項目名稱:oma-riista-android,代碼行數:13,代碼來源:GameHarvest.java

示例6: serializeSessionId

import java.io.ObjectOutputStream; //導入方法依賴的package包/類
/**
 * serialize sessionID
 * @throws IOException if an input/output error occurs
 */
protected byte[] serializeSessionId(String sessionId) throws IOException {
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream(bos);
    oos.writeUTF(sessionId);
    oos.flush();
    oos.close();
    return bos.toByteArray();
}
 
開發者ID:sunmingshuai,項目名稱:apache-tomcat-7.0.73-with-comment,代碼行數:13,代碼來源:DeltaManager.java

示例7: writeUTF

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

示例8: writeSupportVectors

import java.io.ObjectOutputStream; //導入方法依賴的package包/類
/** Writes the example set into the given output stream. */
public void writeSupportVectors(ObjectOutputStream out) throws IOException {
	out.writeInt(getNumberOfSupportVectors());
	out.writeDouble(b);
	out.writeInt(dim);
	if ((meanVarianceMap == null) || (meanVarianceMap.size() == 0)) {
		out.writeUTF("noscale");
	} else {
		out.writeUTF("scale");
		out.writeInt(meanVarianceMap.size());
		Iterator i = meanVarianceMap.keySet().iterator();
		while (i.hasNext()) {
			Integer index = (Integer) i.next();
			MeanVariance meanVariance = meanVarianceMap.get(index);
			out.writeInt(index.intValue());
			out.writeDouble(meanVariance.getMean());
			out.writeDouble(meanVariance.getVariance());
		}
	}
	for (int e = 0; e < train_size; e++) {
		if (alphas[e] != 0.0d) {
			out.writeInt(atts[e].length);
			for (int a = 0; a < atts[e].length; a++) {
				out.writeInt(index[e][a]);
				out.writeDouble(atts[e][a]);
			}
			out.writeDouble(alphas[e]);
			out.writeDouble(ys[e]);
		}
	}
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:32,代碼來源:SVMExamples.java

示例9: writeObject

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

    out.writeUTF(uri != null ? uri.toString() : "");
}
 
開發者ID:suomenriistakeskus,項目名稱:oma-riista-android,代碼行數:6,代碼來源:LogImage.java

示例10: handleLoadFailure

import java.io.ObjectOutputStream; //導入方法依賴的package包/類
private void handleLoadFailure(Throwable ex, ObjectOutputStream out) throws IOException {
    debug("*** Load failure: %s\n", ex);
    out.writeInt(RESULT_FAIL);
    out.writeUTF(ex.toString());
    out.flush();
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:7,代碼來源:RemoteAgent.java

示例11: handleInvocationFailure

import java.io.ObjectOutputStream; //導入方法依賴的package包/類
private void handleInvocationFailure(Throwable ex, ObjectOutputStream out) throws IOException {
    debug("*** Invoke failure: %s -- %s\n", ex, ex.getCause());
    out.writeInt(RESULT_FAIL);
    out.writeUTF(ex.toString());
    out.flush();
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:7,代碼來源:RemoteAgent.java

示例12: writeObject

import java.io.ObjectOutputStream; //導入方法依賴的package包/類
/**
 * <code>writeObject</code> for custom serialization.
 *
 * <p>This method writes this object's serialized form for
 * this class as follows:
 *
 * <p>The <code>writeObject</code> method is invoked on
 * <code>out</code> passing this object's unique identifier
 * (a {@link java.rmi.server.UID UID} instance) as the argument.
 *
 * <p>Next, the {@link
 * java.rmi.server.RemoteRef#getRefClass(java.io.ObjectOutput)
 * getRefClass} method is invoked on the activator's
 * <code>RemoteRef</code> instance to obtain its external ref
 * type name.  Next, the <code>writeUTF</code> method is
 * invoked on <code>out</code> with the value returned by
 * <code>getRefClass</code>, and then the
 * <code>writeExternal</code> method is invoked on the
 * <code>RemoteRef</code> instance passing <code>out</code>
 * as the argument.
 *
 * @serialData The serialized data for this class comprises a
 * <code>java.rmi.server.UID</code> (written with
 * <code>ObjectOutput.writeObject</code>) followed by the
 * external ref type name of the activator's
 * <code>RemoteRef</code> instance (a string written with
 * <code>ObjectOutput.writeUTF</code>), followed by the
 * external form of the <code>RemoteRef</code> instance as
 * written by its <code>writeExternal</code> method.
 *
 * <p>The external ref type name of the
 * <code>RemoteRef</Code> instance is
 * determined using the definitions of external ref type
 * names specified in the {@link java.rmi.server.RemoteObject
 * RemoteObject} <code>writeObject</code> method
 * <b>serialData</b> specification.  Similarly, the data
 * written by the <code>writeExternal</code> method and read
 * by the <code>readExternal</code> method of
 * <code>RemoteRef</code> implementation classes
 * corresponding to each of the defined external ref type
 * names is specified in the {@link
 * java.rmi.server.RemoteObject RemoteObject}
 * <code>writeObject</code> method <b>serialData</b>
 * specification.
 **/
private void writeObject(ObjectOutputStream out)
    throws IOException, ClassNotFoundException
{
    out.writeObject(uid);

    RemoteRef ref;
    if (activator instanceof RemoteObject) {
        ref = ((RemoteObject) activator).getRef();
    } else if (Proxy.isProxyClass(activator.getClass())) {
        InvocationHandler handler = Proxy.getInvocationHandler(activator);
        if (!(handler instanceof RemoteObjectInvocationHandler)) {
            throw new InvalidObjectException(
                "unexpected invocation handler");
        }
        ref = ((RemoteObjectInvocationHandler) handler).getRef();

    } else {
        throw new InvalidObjectException("unexpected activator type");
    }
    out.writeUTF(ref.getRefClass(out));
    ref.writeExternal(out);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:68,代碼來源:ActivationID.java

示例13: 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

示例14: writeObject

import java.io.ObjectOutputStream; //導入方法依賴的package包/類
private void writeObject(ObjectOutputStream out) throws IOException {
    out.defaultWriteObject();
    out.writeUTF(params.id);
}
 
開發者ID:rsksmart,項目名稱:bitcoinj-thin,代碼行數:5,代碼來源:Address.java

示例15: writeObject

import java.io.ObjectOutputStream; //導入方法依賴的package包/類
void writeObject(ObjectOutputStream out) throws IOException {
    out.writeBoolean(positive);
    out.writeUTF(message);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:5,代碼來源:AsyncMessageCommand.java


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