Java Code Examples for java.io.ObjectOutputStream.writeUTF()

The following are Jave code examples for showing how to use writeUTF() of the java.io.ObjectOutputStream class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: incubator-netbeans   File: EventBufferDumpedCommand.java   View Source Code Vote up 6 votes
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);
    }
}
 
Example 2
Project: incubator-netbeans   File: GetClassFileBytesCommand.java   View Source Code Vote up 6 votes
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;
}
 
Example 3
Project: incubator-netbeans   File: ClassLoadedCommand.java   View Source Code Vote up 6 votes
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);
}
 
Example 4
Project: lams   File: SessionFactoryImpl.java   View Source Code Vote up 5 votes
/**
 * 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 );
	}
}
 
Example 5
Project: oma-riista-android   File: GameHarvest.java   View Source Code Vote up 5 votes
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);
}
 
Example 6
Project: apache-tomcat-7.0.73-with-comment   File: DeltaManager.java   View Source Code Vote up 5 votes
/**
 * 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();
}
 
Example 7
Project: jsf-sdk   File: JavaEncoder.java   View Source Code Vote up 5 votes
private void writeUTF(String v, ObjectOutputStream oos) throws IOException	{
	if( v == null ) {
		oos.writeInt(-1);
	} else {
		oos.writeInt(v.length());
		oos.writeUTF(v);
	}
}
 
Example 8
Project: rapidminer   File: SVMExamples.java   View Source Code Vote up 5 votes
/** 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]);
		}
	}
}
 
Example 9
Project: tomcat7   File: DeltaManager.java   View Source Code Vote up 5 votes
/**
 * 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();
}
 
Example 10
Project: oma-riista-android   File: LogImage.java   View Source Code Vote up 4 votes
private void writeObject(ObjectOutputStream out) throws IOException {
    out.defaultWriteObject();

    out.writeUTF(uri != null ? uri.toString() : "");
}
 
Example 11
Project: incubator-netbeans   File: RemoteAgent.java   View Source Code Vote up 4 votes
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();
}
 
Example 12
Project: incubator-netbeans   File: RemoteAgent.java   View Source Code Vote up 4 votes
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();
}
 
Example 13
Project: openjdk-jdk10   File: ActivationID.java   View Source Code Vote up 4 votes
/**
 * <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);
}
 
Example 14
Project: Meucci   File: ModLoader.java   View Source Code Vote up 4 votes
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);
}
 
Example 15
Project: bitcoinj-thin   File: Address.java   View Source Code Vote up 4 votes
private void writeObject(ObjectOutputStream out) throws IOException {
    out.defaultWriteObject();
    out.writeUTF(params.id);
}
 
Example 16
Project: incubator-netbeans   File: AsyncMessageCommand.java   View Source Code Vote up 4 votes
void writeObject(ObjectOutputStream out) throws IOException {
    out.writeBoolean(positive);
    out.writeUTF(message);
}
 
Example 17
Project: okwallet   File: BIP38PrivateKey.java   View Source Code Vote up 4 votes
private void writeObject(ObjectOutputStream out) throws IOException {
    out.defaultWriteObject();
    out.writeUTF(params.getId());
}
 
Example 18
Project: incubator-netbeans   File: TakeHeapDumpCommand.java   View Source Code Vote up 4 votes
void writeObject(ObjectOutputStream out) throws IOException {
    out.writeUTF(outputFile);
}
 
Example 19
Project: morpheus-core   File: ArrayBase.java   View Source Code Vote up 4 votes
/** Custom serialization */
private void writeObject(ObjectOutputStream os) throws IOException {
    os.writeObject(type);
    os.writeUTF(style.name());
    os.writeBoolean(parallel);
}
 
Example 20
Project: OpenJSharp   File: ActivationID.java   View Source Code Vote up 4 votes
/**
 * <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);
}