Java Code Examples for java.io.ObjectOutputStream#write()
The following examples show how to use
java.io.ObjectOutputStream#write() .
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: CertificateRevokedException.java From JDKSourceCode1.8 with MIT License | 6 votes |
/** * 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); } }
Example 2
Source File: SimpleTimeZone.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
/** * 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); }
Example 3
Source File: SimpleTimeZone.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * 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); }
Example 4
Source File: CertificateRevokedException.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * 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); } }
Example 5
Source File: SimpleTimeZone.java From Bytecoder with Apache License 2.0 | 6 votes |
/** * 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} 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 startDayOfWeek}, * {@code endDay}, and {@code endDayOfWeek}. The values of these * fields in the required section are approximate values suited to the rule * mode {@code DOW_IN_MONTH_MODE}, which is the only mode recognized by * JDK 1.1. */ @java.io.Serial 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); }
Example 6
Source File: SimpleTimeZone.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
/** * 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); }
Example 7
Source File: SimpleTimeZone.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
/** * 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); }
Example 8
Source File: SimpleTimeZone.java From jdk1.8-source-analysis with Apache License 2.0 | 6 votes |
/** * 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); }
Example 9
Source File: EventBufferDumpedCommand.java From visualvm with GNU General Public License v2.0 | 6 votes |
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); } }
Example 10
Source File: ObjectWithSerializationError.java From reladomo with Apache License 2.0 | 5 votes |
private void writeObject(ObjectOutputStream out) throws IOException { byte[] bytes = this.contents.getBytes("ISO8859_1"); out.writeInt(bytes.length); if (this.exceptionThrown) { out.write(bytes); } else { out.write(bytes, 0, bytes.length / 2); this.exceptionThrown = true; throw new IOException(); } }
Example 11
Source File: StubIORImpl.java From hottub with GNU General Public License v2.0 | 5 votes |
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]); } }
Example 12
Source File: MethodNamesResponse.java From visualvm with GNU General Public License v2.0 | 5 votes |
void writeObject(ObjectOutputStream out) throws IOException { out.writeInt(packedData.length); out.write(packedData); out.writeInt(packedArrayOffsets.length); for (int i = 0; i < packedArrayOffsets.length; i++) { out.writeInt(packedArrayOffsets[i]); } packedData = null; packedArrayOffsets = null; }
Example 13
Source File: MBeanFeatureInfo.java From hottub with GNU General Public License v2.0 | 4 votes |
/** * 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); } }
Example 14
Source File: MBeanInfo.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
/** * 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); } }
Example 15
Source File: MBeanInfo.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
/** * 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); } }
Example 16
Source File: UTF8BytesLinkObj.java From multiple-dimension-spread with Apache License 2.0 | 4 votes |
private void writeObject( final ObjectOutputStream out ) throws IOException{ out.write( length ); out.write( value , start , length ); }
Example 17
Source File: MBeanInfo.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
/** * 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); } }
Example 18
Source File: MBeanFeatureInfo.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
/** * 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); } }
Example 19
Source File: MBeanFeatureInfo.java From JDKSourceCode1.8 with MIT License | 4 votes |
/** * 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); } }
Example 20
Source File: MBeanFeatureInfo.java From Java8CN with Apache License 2.0 | 4 votes |
/** * 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); } }