当前位置: 首页>>代码示例>>Java>>正文


Java ObjectOutputStream.write方法代码示例

本文整理汇总了Java中java.io.ObjectOutputStream.write方法的典型用法代码示例。如果您正苦于以下问题:Java ObjectOutputStream.write方法的具体用法?Java ObjectOutputStream.write怎么用?Java ObjectOutputStream.write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.io.ObjectOutputStream的用法示例。


在下文中一共展示了ObjectOutputStream.write方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: writeObject

import java.io.ObjectOutputStream; //导入方法依赖的package包/类
/**
 * Save the state of this object to a stream (i.e., serialize it).
 *
 * @serialData We write out two formats, a JDK 1.1 compatible format, using
 * <code>DOW_IN_MONTH_MODE</code> rules, in the required section, followed
 * by the full rules, in packed format, in the optional section.  The
 * optional section will be ignored by JDK 1.1 code upon stream in.
 * <p> Contents of the optional section: The length of a byte array is
 * emitted (int); this is 4 as of this release. The byte array of the given
 * length is emitted. The contents of the byte array are the true values of
 * the fields <code>startDay</code>, <code>startDayOfWeek</code>,
 * <code>endDay</code>, and <code>endDayOfWeek</code>.  The values of these
 * fields in the required section are approximate values suited to the rule
 * mode <code>DOW_IN_MONTH_MODE</code>, which is the only mode recognized by
 * JDK 1.1.
 */
private void writeObject(ObjectOutputStream stream)
     throws IOException
{
    // Construct a binary rule
    byte[] rules = packRules();
    int[] times = packTimes();

    // Convert to 1.1 FCS rules.  This step may cause us to lose information.
    makeRulesCompatible();

    // Write out the 1.1 FCS rules
    stream.defaultWriteObject();

    // Write out the binary rules in the optional data area of the stream.
    stream.writeInt(rules.length);
    stream.write(rules);
    stream.writeObject(times);

    // Recover the original rules.  This recovers the information lost
    // by makeRulesCompatible.
    unpackRules(rules);
    unpackTimes(times);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:40,代码来源:SimpleTimeZone.java

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

示例3: writeObject

import java.io.ObjectOutputStream; //导入方法依赖的package包/类
/**
 * Serialize this {@code CertificateRevokedException} instance.
 *
 * @serialData the size of the extensions map (int), followed by all of
 * the extensions in the map, in no particular order. For each extension,
 * the following data is emitted: the OID String (Object), the criticality
 * flag (boolean), the length of the encoded extension value byte array
 * (int), and the encoded extension value bytes.
 */
private void writeObject(ObjectOutputStream oos) throws IOException {
    // Write out the non-transient fields
    // (revocationDate, reason, authority)
    oos.defaultWriteObject();

    // Write out the size (number of mappings) of the extensions map
    oos.writeInt(extensions.size());

    // For each extension in the map, the following are emitted (in order):
    // the OID String (Object), the criticality flag (boolean), the length
    // of the encoded extension value byte array (int), and the encoded
    // extension value byte array. The extensions themselves are emitted
    // in no particular order.
    for (Map.Entry<String, Extension> entry : extensions.entrySet()) {
        Extension ext = entry.getValue();
        oos.writeObject(ext.getId());
        oos.writeBoolean(ext.isCritical());
        byte[] extVal = ext.getValue();
        oos.writeInt(extVal.length);
        oos.write(extVal);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:32,代码来源:CertificateRevokedException.java

示例4: writeMetadata

import java.io.ObjectOutputStream; //导入方法依赖的package包/类
private void writeMetadata(final ObjectOutputStream oos) throws IOException {
	oos.writeLong(byteArrayDiskQueues.size);
	oos.writeLong(byteArrayDiskQueues.appendPointer);
	oos.writeLong(byteArrayDiskQueues.used);
	oos.writeLong(byteArrayDiskQueues.allocated);
	oos.writeInt(byteArrayDiskQueues.buffers.size());
	oos.writeInt(byteArrayDiskQueues.key2QueueData.size());
	final ObjectIterator<Reference2ObjectMap.Entry<Object, QueueData>> fastIterator = byteArrayDiskQueues.key2QueueData.reference2ObjectEntrySet().fastIterator();
	for(int i = byteArrayDiskQueues.key2QueueData.size(); i-- != 0;) {
		final Reference2ObjectMap.Entry<Object, QueueData> next = fastIterator.next();
		final VisitState visitState = (VisitState)next.getKey();
		// TODO: temporary, to catch serialization bug
		if (visitState == null) {
			LOGGER.error("Map iterator returned null key");
			continue;
		}
		else if (visitState.schemeAuthority == null) LOGGER.error("Map iterator returned visit state with null schemeAuthority");
		else Util.writeVByte(visitState.schemeAuthority.length, oos);
		oos.write(visitState.schemeAuthority);
		oos.writeObject(next.getValue());
	}

	oos.close();
}
 
开发者ID:LAW-Unimi,项目名称:BUbiNG,代码行数:25,代码来源:WorkbenchVirtualizer.java

示例5: doWrite

import java.io.ObjectOutputStream; //导入方法依赖的package包/类
public  void doWrite( ObjectOutputStream stream )
    throws IOException
{
    // write the IOR to the ObjectOutputStream
    stream.writeInt(typeData.length);
    stream.write(typeData);
    stream.writeInt(profileTags.length);
    for (int i = 0; i < profileTags.length; i++) {
        stream.writeInt(profileTags[i]);
        stream.writeInt(profileData[i].length);
        stream.write(profileData[i]);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:StubIORImpl.java

示例6: writeObject

import java.io.ObjectOutputStream; //导入方法依赖的package包/类
void writeObject(ObjectOutputStream out) throws IOException {
    out.writeInt(classBytes.length);

    for (int i = 0; i < classBytes.length; i++) {
        if (classBytes[i] == null) {
            out.writeInt(0);
        } else {
            out.writeInt(classBytes[i].length);
            out.write(classBytes[i]);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:GetClassFileBytesResponse.java

示例7: writeObject

import java.io.ObjectOutputStream; //导入方法依赖的package包/类
private synchronized void writeObject(ObjectOutputStream stream)
    throws IOException {
    try {
        stream.write(getEncoded());
    } catch (CertificateEncodingException e) {
        throw new IOException("getEncoded failed: " + e.getMessage());
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:9,代码来源:X509V1CertImpl.java

示例8: writeObject

import java.io.ObjectOutputStream; //导入方法依赖的package包/类
void writeObject(ObjectOutputStream out) throws IOException {
    if (instrMethodClasses == null) {
        out.writeInt(0);

        return;
    }

    out.writeInt(nClasses);

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

    out.writeInt(nMethods);

    if (instrMethodLeaf != null) {
        out.write(1);

        for (int i = 0; i < nMethods; i++) {
            out.writeBoolean(instrMethodLeaf[i]);
        }
    } else {
        out.write(0);
    }

    out.writeInt(addInfo);

    for (int i = 0; i < nClasses; i++) {
        if (replacementClassFileBytes[i] == null) {
            out.writeInt(0);
        } else {
            out.writeInt(replacementClassFileBytes[i].length);
            out.write(replacementClassFileBytes[i]);
        }
    }

    instrMethodClasses = null;
    instrMethodClassLoaderIds = null;
    instrMethodLeaf = null;
    replacementClassFileBytes = null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:43,代码来源:InstrumentMethodGroupData.java

示例9: writeObject

import java.io.ObjectOutputStream; //导入方法依赖的package包/类
/**
 * Serializes an {@link MBeanInfo} to an {@link ObjectOutputStream}.
 * @serialData
 * For compatibility reasons, an object of this class is serialized as follows.
 * <p>
 * The method {@link ObjectOutputStream#defaultWriteObject defaultWriteObject()}
 * is called first to serialize the object except the field {@code descriptor}
 * which is declared as transient. The field {@code descriptor} is serialized
 * as follows:
 *     <ul>
 *     <li> If {@code descriptor} is an instance of the class
 *        {@link ImmutableDescriptor}, the method {@link ObjectOutputStream#write
 *        write(int val)} is called to write a byte with the value {@code 1},
 *        then the method {@link ObjectOutputStream#writeObject writeObject(Object obj)}
 *        is called twice to serialize the field names and the field values of the
 *        {@code descriptor}, respectively as a {@code String[]} and an
 *        {@code Object[]};</li>
 *     <li> Otherwise, the method {@link ObjectOutputStream#write write(int val)}
 *        is called to write a byte with the value {@code 0}, then the method
 *        {@link ObjectOutputStream#writeObject writeObject(Object obj)} is called
 *        to serialize the field {@code descriptor} directly.
 *     </ul>
 *
 * @since 1.6
 */
private void writeObject(ObjectOutputStream out) throws IOException {
    out.defaultWriteObject();

    if (descriptor.getClass() == ImmutableDescriptor.class) {
        out.write(1);

        final String[] names = descriptor.getFieldNames();

        out.writeObject(names);
        out.writeObject(descriptor.getFieldValues(names));
    } else {
        out.write(0);

        out.writeObject(descriptor);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:42,代码来源:MBeanInfo.java

示例10: writeObject

import java.io.ObjectOutputStream; //导入方法依赖的package包/类
void writeObject(ObjectOutputStream out) throws IOException {
    out.writeInt(status.length);
    out.write(status);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:5,代码来源:ThreadLivenessStatusResponse.java

示例11: writeObject

import java.io.ObjectOutputStream; //导入方法依赖的package包/类
/**
 * Serializes an {@link MBeanFeatureInfo} to an {@link ObjectOutputStream}.
 * @serialData
 * For compatibility reasons, an object of this class is serialized as follows.
 * <p>
 * The method {@link ObjectOutputStream#defaultWriteObject defaultWriteObject()}
 * is called first to serialize the object except the field {@code descriptor}
 * which is declared as transient. The field {@code descriptor} is serialized
 * as follows:
 *     <ul>
 *     <li>If {@code descriptor} is an instance of the class
 *        {@link ImmutableDescriptor}, the method {@link ObjectOutputStream#write
 *        write(int val)} is called to write a byte with the value {@code 1},
 *        then the method {@link ObjectOutputStream#writeObject writeObject(Object obj)}
 *        is called twice to serialize the field names and the field values of the
 *        {@code descriptor}, respectively as a {@code String[]} and an
 *        {@code Object[]};</li>
 *     <li>Otherwise, the method {@link ObjectOutputStream#write write(int val)}
 * is called to write a byte with the value {@code 0}, then the method
 * {@link ObjectOutputStream#writeObject writeObject(Object obj)} is called
 * to serialize directly the field {@code descriptor}.
 *     </ul>
 *
 * @since 1.6
 */
private void writeObject(ObjectOutputStream out) throws IOException {
    out.defaultWriteObject();

    if (descriptor != null &&
        descriptor.getClass() == ImmutableDescriptor.class) {

        out.write(1);

        final String[] names = descriptor.getFieldNames();

        out.writeObject(names);
        out.writeObject(descriptor.getFieldValues(names));
    } else {
        out.write(0);

        out.writeObject(descriptor);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:44,代码来源:MBeanFeatureInfo.java

示例12: writeObject

import java.io.ObjectOutputStream; //导入方法依赖的package包/类
private void writeObject(ObjectOutputStream out) throws IOException {
  byte[] serialized = metadata.serialize();
  out.writeInt(serialized.length);
  out.write(serialized);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:6,代码来源:JavaKeyStoreProvider.java

示例13: writeObject

import java.io.ObjectOutputStream; //导入方法依赖的package包/类
/**
 * Serializes this node into the target stream.
 * 
 * @param out
 *            target stream
 * 
 * @throws IOException
 *             any I/O exception
 */
private void writeObject(ObjectOutputStream out) throws IOException {
	out.defaultWriteObject();
	byte[] bytes = JavaBuiltin.serialize(value, meta, true);
	out.writeInt(bytes.length);
	out.write(bytes);
}
 
开发者ID:berkesa,项目名称:datatree,代码行数:16,代码来源:Tree.java

示例14: writeByteArray

import java.io.ObjectOutputStream; //导入方法依赖的package包/类
/** Writes a byte array prefixed by its length encoded using vByte.
 *
 * @param a the array to be written.
 * @param s the stream where the array should be written.
 */
public final static void writeByteArray(final byte[] a, final ObjectOutputStream s) throws IOException {
	writeVByte(a.length, s);
	s.write(a);
}
 
开发者ID:LAW-Unimi,项目名称:BUbiNG,代码行数:10,代码来源:Util.java


注:本文中的java.io.ObjectOutputStream.write方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。