本文整理汇总了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);
}
}
示例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;
}
示例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);
}
示例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 );
}
}
示例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);
}
示例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();
}
示例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);
}
}
示例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]);
}
}
}
示例9: writeObject
import java.io.ObjectOutputStream; //导入方法依赖的package包/类
private void writeObject(ObjectOutputStream out) throws IOException {
out.defaultWriteObject();
out.writeUTF(uri != null ? uri.toString() : "");
}
示例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();
}
示例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();
}
示例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);
}
示例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);
}
示例14: writeObject
import java.io.ObjectOutputStream; //导入方法依赖的package包/类
private void writeObject(ObjectOutputStream out) throws IOException {
out.defaultWriteObject();
out.writeUTF(params.id);
}
示例15: writeObject
import java.io.ObjectOutputStream; //导入方法依赖的package包/类
void writeObject(ObjectOutputStream out) throws IOException {
out.writeBoolean(positive);
out.writeUTF(message);
}