java.io.ObjectOutputStream#writeUTF ( )源码实例Demo

下面列出了java.io.ObjectOutputStream#writeUTF ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: HotswapAgent   文件: AppletServer.java
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();
}
 
源代码2 项目: flink   文件: RemoteRpcInvocation.java
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);
	}
}
 
源代码3 项目: android_tv_metro   文件: DiskBasedCache.java
/**
 * 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;
    }
}
 
源代码4 项目: visualvm   文件: HeapHistogramResponse.java
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;
}
 
源代码5 项目: CupDnn   文件: InputLayer.java
@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();
	}
}
 
源代码6 项目: phrasal   文件: RichTranslation.java
/**
 * 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);
}
 
源代码7 项目: Flink-CEPplus   文件: HCatInputFormatBase.java
private void writeObject(ObjectOutputStream out) throws IOException {
	out.writeInt(this.fieldNames.length);
	for (String fieldName : this.fieldNames) {
		out.writeUTF(fieldName);
	}
	this.configuration.write(out);
}
 
源代码8 项目: logging-log4j2   文件: StringFormattedMessage.java
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;
    }
}
 
public void write(ObjectOutputStream os,
                  Object object) throws IOException {
    ProcessInstance processInstance = (ProcessInstance) object;

    connectProcessInstanceToRuntimeAndProcess( processInstance, os );

    os.writeUTF( processInstance.getId() );
}
 
源代码10 项目: flink   文件: HCatInputFormatBase.java
private void writeObject(ObjectOutputStream out) throws IOException {
	out.writeInt(this.fieldNames.length);
	for (String fieldName : this.fieldNames) {
		out.writeUTF(fieldName);
	}
	this.configuration.write(out);
}
 
源代码11 项目: super-cloudops   文件: IamSession.java
/**
 * 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);
	}
}
 
源代码12 项目: barleydb   文件: ToManyNode.java
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);
}
 
源代码13 项目: dragonwell8_jdk   文件: ActivationID.java
/**
 * <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);
}
 
源代码14 项目: netbeans   文件: MonitoredNumbersResponse.java
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);
}
 
源代码15 项目: coming   文件: Cardumen_00189_t.java
private void writeObject(ObjectOutputStream out) throws IOException {
    out.writeUTF(iID);
}
 
源代码16 项目: coming   文件: Cardumen_0074_s.java
private void writeObject(ObjectOutputStream out) throws IOException {
    out.writeUTF(iID);
}
 
源代码17 项目: bcm-android   文件: PrefixedChecksummedBytes.java
private void writeObject(ObjectOutputStream out) throws IOException {
    out.defaultWriteObject();
    out.writeUTF(params.getId());
}
 
源代码18 项目: netbeans   文件: GetDefiningClassLoaderCommand.java
void writeObject(ObjectOutputStream out) throws IOException {
    out.writeUTF(className);
    out.writeInt(classLoaderId);
}
 
源代码19 项目: webarchive-commons   文件: UsableURI.java
private void writeObject(ObjectOutputStream stream) throws IOException {
  stream.writeUTF(toCustomString());
}
 
源代码20 项目: openjdk-jdk8u-backup   文件: ActivationID.java
/**
 * <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);
}