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

The following examples show how to use java.io.ObjectOutputStream#writeUTF() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AppletServer.java    From HotswapAgent with GNU General Public License v2.0 6 votes vote down vote up
private void lookupName(String cmd, InputStream ins, OutputStream outs)
    throws IOException
{
    ObjectInputStream in = new ObjectInputStream(ins);
    String name = DataInputStream.readUTF(in);
    ExportedObject found = exportedNames.get(name);
    outs.write(okHeader);
    ObjectOutputStream out = new ObjectOutputStream(outs);
    if (found == null) {
        logging2(name + "not found.");
        out.writeInt(-1);           // error code
        out.writeUTF("error");
    }
    else {
        logging2(name);
        out.writeInt(found.identifier);
        out.writeUTF(found.object.getClass().getName());
    }

    out.flush();
    out.close();
    in.close();
}
 
Example 2
Source File: DiskBasedCache.java    From android_tv_metro with Apache License 2.0 6 votes vote down vote up
/**
 * Writes the contents of this CacheHeader to the specified OutputStream.
 */
public boolean writeHeader(OutputStream os) {
    try {
        ObjectOutputStream oos = new ObjectOutputStream(os);
        oos.writeByte(CACHE_VERSION);
        oos.writeUTF(key);
        oos.writeUTF(etag == null ? "" : etag);
        oos.writeLong(serverDate);
        oos.writeLong(ttl);
        oos.writeLong(softTtl);
        writeStringStringMap(responseHeaders, oos);
        oos.flush();
        return true;
    } catch (IOException e) {
        VolleyLog.d("%s", e.toString());
        return false;
    }
}
 
Example 3
Source File: RemoteRpcInvocation.java    From flink with Apache License 2.0 6 votes vote down vote up
private void writeObject(ObjectOutputStream oos) throws IOException {
	oos.writeUTF(methodName);

	oos.writeInt(parameterTypes.length);

	for (Class<?> parameterType : parameterTypes) {
		oos.writeObject(parameterType);
	}

	if (args != null) {
		oos.writeBoolean(true);

		for (int i = 0; i < args.length; i++) {
			try {
				oos.writeObject(args[i]);
			} catch (IOException e) {
				throw new IOException("Could not serialize " + i + "th argument of method " +
					methodName + ". This indicates that the argument type " +
					args.getClass().getName() + " is not serializable. Arguments have to " +
					"be serializable for remote rpc calls.", e);
			}
		}
	} else {
		oos.writeBoolean(false);
	}
}
 
Example 4
Source File: RichTranslation.java    From phrasal with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Custom serializer.
 * 
 * @param oos
 */
private void writeObject(ObjectOutputStream oos) throws IOException {
  oos.defaultWriteObject();
  oos.writeLong(latticeSourceId);
  oos.writeDouble(score);
  oos.writeUTF(source.toString());
  oos.writeUTF(translation.toString());
  oos.writeUTF(f2eAlignment == null ? alignmentString() : f2eAlignment);
  oos.writeObject(this.features);
}
 
Example 5
Source File: HCatInputFormatBase.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
private void writeObject(ObjectOutputStream out) throws IOException {
	out.writeInt(this.fieldNames.length);
	for (String fieldName : this.fieldNames) {
		out.writeUTF(fieldName);
	}
	this.configuration.write(out);
}
 
Example 6
Source File: StringFormattedMessage.java    From logging-log4j2 with Apache License 2.0 5 votes vote down vote up
private void writeObject(final ObjectOutputStream out) throws IOException {
    out.defaultWriteObject();
    getFormattedMessage();
    out.writeUTF(formattedMessage);
    out.writeUTF(messagePattern);
    out.writeInt(argArray.length);
    stringArgs = new String[argArray.length];
    int i = 0;
    for (final Object obj : argArray) {
        final String string = String.valueOf(obj);
        stringArgs[i] = string;
        out.writeUTF(string);
        ++i;
    }
}
 
Example 7
Source File: HeapHistogramResponse.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
void writeObject(ObjectOutputStream out) throws IOException {
    out.writeLong(time.getTime());
    out.writeInt(newNames.length);
    for (int i = 0; i < newNames.length; i++) {
        out.writeUTF(newNames[i]);
    }
    out.writeInt(newids.length);
    for (int i = 0; i < newids.length; i++) {
        out.writeInt(newids[i]);
    }
    out.writeInt(ids.length);
    for (int i = 0; i < ids.length; i++) {
        out.writeInt(ids[i]);
    }
    out.writeInt(instances.length);
    for (int i = 0; i < instances.length; i++) {
        out.writeLong(instances[i]);
    }
    out.writeInt(bytes.length);
    for (int i = 0; i < bytes.length; i++) {
        out.writeLong(bytes[i]);
    }
    newNames = null;
    newids = null;
    ids = null;
    instances = null;
    bytes = null;
}
 
Example 8
Source File: InputLayer.java    From CupDnn with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void saveModel(ObjectOutputStream out) {
	// TODO Auto-generated method stub
	try {
		out.writeUTF(getType());
		//�����ʱ��batchҲ����layerParams��number����1����Ϊpredict��ʱ����Ϊ����ʹ�õ�ʱ�����batchһ�㶼��1
		out.writeInt(width);
		out.writeInt(height);
		out.writeInt(channel);
	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
}
 
Example 9
Source File: ProcessInstanceResolverStrategy.java    From kogito-runtimes with Apache License 2.0 5 votes vote down vote up
public void write(ObjectOutputStream os,
                  Object object) throws IOException {
    ProcessInstance processInstance = (ProcessInstance) object;

    connectProcessInstanceToRuntimeAndProcess( processInstance, os );

    os.writeUTF( processInstance.getId() );
}
 
Example 10
Source File: HCatInputFormatBase.java    From flink with Apache License 2.0 5 votes vote down vote up
private void writeObject(ObjectOutputStream out) throws IOException {
	out.writeInt(this.fieldNames.length);
	for (String fieldName : this.fieldNames) {
		out.writeUTF(fieldName);
	}
	this.configuration.write(out);
}
 
Example 11
Source File: IamSession.java    From super-cloudops with Apache License 2.0 5 votes vote down vote up
/**
 * Serializes this object to the specified output stream for JDK
 * Serialization.
 *
 * @param out
 *            output stream used for Object serialization.
 * @throws IOException
 *             if any of this object's fields cannot be written to the
 *             stream.
 * @since 1.0
 */
@JsonIgnore
private void writeObject(ObjectOutputStream out) throws IOException {
	out.defaultWriteObject();
	short alteredFieldsBitMask = getAlteredFieldsBitMask();
	out.writeShort(alteredFieldsBitMask);
	if (id != null) {
		out.writeObject(id);
	}
	if (startTimestamp != null) {
		out.writeObject(startTimestamp);
	}
	if (stopTimestamp != null) {
		out.writeObject(stopTimestamp);
	}
	if (lastAccessTime != null) {
		out.writeObject(lastAccessTime);
	}
	if (timeout != 0l) {
		out.writeLong(timeout);
	}
	if (expired) {
		out.writeBoolean(expired);
	}
	if (host != null) {
		out.writeUTF(host);
	}
	if (!CollectionUtils.isEmpty(attributes)) {
		out.writeObject(attributes);
	}
}
 
Example 12
Source File: ToManyNode.java    From barleydb with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void writeObject(ObjectOutputStream oos) throws IOException {
    LOG.trace("Serializing many references {}", this);
    oos.writeUTF(entityType.getInterfaceName());
    oos.writeBoolean(fetched);
    oos.writeObject(entities);
    oos.writeObject(newEntities);
}
 
Example 13
Source File: Cardumen_0074_s.java    From coming with MIT License 4 votes vote down vote up
private void writeObject(ObjectOutputStream out) throws IOException {
    out.writeUTF(iID);
}
 
Example 14
Source File: ActivationID.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * <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 15
Source File: UsableURI.java    From webarchive-commons with Apache License 2.0 4 votes vote down vote up
private void writeObject(ObjectOutputStream stream) throws IOException {
  stream.writeUTF(toCustomString());
}
 
Example 16
Source File: GetDefiningClassLoaderCommand.java    From netbeans with Apache License 2.0 4 votes vote down vote up
void writeObject(ObjectOutputStream out) throws IOException {
    out.writeUTF(className);
    out.writeInt(classLoaderId);
}
 
Example 17
Source File: PrefixedChecksummedBytes.java    From bcm-android with GNU General Public License v3.0 4 votes vote down vote up
private void writeObject(ObjectOutputStream out) throws IOException {
    out.defaultWriteObject();
    out.writeUTF(params.getId());
}
 
Example 18
Source File: ActivationID.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * <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 19
Source File: Cardumen_00189_t.java    From coming with MIT License 4 votes vote down vote up
private void writeObject(ObjectOutputStream out) throws IOException {
    out.writeUTF(iID);
}
 
Example 20
Source File: MonitoredNumbersResponse.java    From netbeans with Apache License 2.0 4 votes vote down vote up
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);
}