當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。