Java Code Examples for java.io.ObjectOutputStream#writeByte()
The following examples show how to use
java.io.ObjectOutputStream#writeByte() .
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: Bytes.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
/** * Run benchmark for given number of batches, with given number of cycles * for each batch. */ void doReps(ObjectOutputStream oout, ObjectInputStream oin, StreamBuffer sbuf, int nbatches, int ncycles) throws Exception { for (int i = 0; i < nbatches; i++) { sbuf.reset(); for (int j = 0; j < ncycles; j++) { oout.writeByte(0); } oout.flush(); for (int j = 0; j < ncycles; j++) { oin.readByte(); } } }
Example 2
Source File: Bytes.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * Run benchmark for given number of batches, with given number of cycles * for each batch. */ void doReps(ObjectOutputStream oout, ObjectInputStream oin, StreamBuffer sbuf, int nbatches, int ncycles) throws Exception { for (int i = 0; i < nbatches; i++) { sbuf.reset(); for (int j = 0; j < ncycles; j++) { oout.writeByte(0); } oout.flush(); for (int j = 0; j < ncycles; j++) { oin.readByte(); } } }
Example 3
Source File: Bytes.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * Run benchmark for given number of batches, with given number of cycles * for each batch. */ void doReps(ObjectOutputStream oout, ObjectInputStream oin, StreamBuffer sbuf, int nbatches, int ncycles) throws Exception { for (int i = 0; i < nbatches; i++) { sbuf.reset(); for (int j = 0; j < ncycles; j++) { oout.writeByte(0); } oout.flush(); for (int j = 0; j < ncycles; j++) { oin.readByte(); } } }
Example 4
Source File: DiskBasedCache.java From android_tv_metro with Apache License 2.0 | 6 votes |
/** * 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; } }
Example 5
Source File: Bytes.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
/** * Run benchmark for given number of batches, with given number of cycles * for each batch. */ void doReps(ObjectOutputStream oout, ObjectInputStream oin, StreamBuffer sbuf, int nbatches, int ncycles) throws Exception { for (int i = 0; i < nbatches; i++) { sbuf.reset(); for (int j = 0; j < ncycles; j++) { oout.writeByte(0); } oout.flush(); for (int j = 0; j < ncycles; j++) { oin.readByte(); } } }
Example 6
Source File: Bytes.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
/** * Run benchmark for given number of batches, with given number of cycles * for each batch. */ void doReps(ObjectOutputStream oout, ObjectInputStream oin, StreamBuffer sbuf, int nbatches, int ncycles) throws Exception { for (int i = 0; i < nbatches; i++) { sbuf.reset(); for (int j = 0; j < ncycles; j++) { oout.writeByte(0); } oout.flush(); for (int j = 0; j < ncycles; j++) { oin.readByte(); } } }
Example 7
Source File: Bytes.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * Run benchmark for given number of batches, with given number of cycles * for each batch. */ void doReps(ObjectOutputStream oout, ObjectInputStream oin, StreamBuffer sbuf, int nbatches, int ncycles) throws Exception { for (int i = 0; i < nbatches; i++) { sbuf.reset(); for (int j = 0; j < ncycles; j++) { oout.writeByte(0); } oout.flush(); for (int j = 0; j < ncycles; j++) { oin.readByte(); } } }
Example 8
Source File: Bytes.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Run benchmark for given number of batches, with given number of cycles * for each batch. */ void doReps(ObjectOutputStream oout, ObjectInputStream oin, StreamBuffer sbuf, int nbatches, int ncycles) throws Exception { for (int i = 0; i < nbatches; i++) { sbuf.reset(); for (int j = 0; j < ncycles; j++) { oout.writeByte(0); } oout.flush(); for (int j = 0; j < ncycles; j++) { oin.readByte(); } } }
Example 9
Source File: ServerDataBox.java From sofa-registry with Apache License 2.0 | 6 votes |
private void writeObject(ObjectOutputStream out) throws IOException { if (isInBytes()) { out.writeByte(serialization); // Write serialization type out.writeInt(bytes.length); // Write byte stream size out.write(bytes); // Write the byte stream } else { ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream javaos = new ObjectOutputStream(bos); try { javaos.writeObject(object); } finally { try { javaos.close(); } catch (IOException ioe) { //do nothing } } out.writeByte(SERIALIZED_BY_JAVA); // Write serialization type out.writeInt(bos.size()); // Write byte stream size out.write(bos.toByteArray()); // Write the byte stream } }
Example 10
Source File: MemberBox.java From openbd-core with GNU General Public License v3.0 | 6 votes |
/** * Writes an array of parameter types to the stream. * * Requires special handling because primitive types cannot be * found upon deserialization by the default Java implementation. */ private static void writeParameters(ObjectOutputStream out, Class<?>[] parms) throws IOException { out.writeShort(parms.length); outer: for (int i=0; i < parms.length; i++) { Class<?> parm = parms[i]; boolean primitive = parm.isPrimitive(); out.writeBoolean(primitive); if (!primitive) { out.writeObject(parm); continue; } for (int j=0; j < primitives.length; j++) { if (parm.equals(primitives[j])) { out.writeByte(j); continue outer; } } throw new IllegalArgumentException("Primitive " + parm + " not found"); } }
Example 11
Source File: CustomObjTrees.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private void writeObject(ObjectOutputStream out) throws IOException { out.writeBoolean(z); out.writeByte(b); out.writeChar(c); out.writeShort(s); out.writeInt(i); out.writeFloat(f); out.writeLong(j); out.writeDouble(d); out.writeObject(str); out.writeObject(parent); out.writeObject(left); out.writeObject(right); }
Example 12
Source File: CustomObjTrees.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private void writeObject(ObjectOutputStream out) throws IOException { out.writeBoolean(z); out.writeByte(b); out.writeChar(c); out.writeShort(s); out.writeInt(i); out.writeFloat(f); out.writeLong(j); out.writeDouble(d); out.writeObject(str); out.writeObject(parent); out.writeObject(left); out.writeObject(right); }
Example 13
Source File: OperationCodec.java From terracotta-platform with Apache License 2.0 | 5 votes |
public static byte[] encode(MapOperation operation) throws IOException { ByteArrayOutputStream byteOut = new ByteArrayOutputStream(); ObjectOutputStream output = new ObjectOutputStream(byteOut); output.writeByte(operation.operationType().ordinal()); operation.writeTo(output); output.close(); return byteOut.toByteArray(); }
Example 14
Source File: CustomObjTrees.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
private void writeObject(ObjectOutputStream out) throws IOException { out.writeBoolean(z); out.writeByte(b); out.writeChar(c); out.writeShort(s); out.writeInt(i); out.writeFloat(f); out.writeLong(j); out.writeDouble(d); out.writeObject(str); out.writeObject(parent); out.writeObject(left); out.writeObject(right); }
Example 15
Source File: CustomObjTrees.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
private void writeObject(ObjectOutputStream out) throws IOException { out.writeBoolean(z); out.writeByte(b); out.writeChar(c); out.writeShort(s); out.writeInt(i); out.writeFloat(f); out.writeLong(j); out.writeDouble(d); out.writeObject(str); out.writeObject(parent); out.writeObject(left); out.writeObject(right); }
Example 16
Source File: ResponseCodec.java From terracotta-platform with Apache License 2.0 | 5 votes |
public static byte[] encode(MapResponse response) throws IOException { ByteArrayOutputStream byteOut = new ByteArrayOutputStream(); ObjectOutputStream output = new ObjectOutputStream(byteOut); output.writeByte(response.responseType().ordinal()); response.writeTo(output); output.close(); return byteOut.toByteArray(); }
Example 17
Source File: LogRecord.java From jtransc with Apache License 2.0 | 5 votes |
private void writeObject(ObjectOutputStream out) throws IOException { out.defaultWriteObject(); out.writeByte(MAJOR); out.writeByte(MINOR); if (parameters == null) { out.writeInt(-1); } else { out.writeInt(parameters.length); for (Object element : parameters) { out.writeObject((element == null) ? null : element.toString()); } } }
Example 18
Source File: JRMPListener.java From ysoserial-modified with MIT License | 4 votes |
private void doCall ( DataInputStream in, DataOutputStream out, Object payload ) throws Exception { ObjectInputStream ois = new ObjectInputStream(in) { @Override protected Class<?> resolveClass ( ObjectStreamClass desc ) throws IOException, ClassNotFoundException { if ( "[Ljava.rmi.server.ObjID;".equals(desc.getName())) { return ObjID[].class; } else if ("java.rmi.server.ObjID".equals(desc.getName())) { return ObjID.class; } else if ( "java.rmi.server.UID".equals(desc.getName())) { return UID.class; } throw new IOException("Not allowed to read object"); } }; ObjID read; try { read = ObjID.read(ois); } catch ( java.io.IOException e ) { throw new MarshalException("unable to read objID", e); } if ( read.hashCode() == 2 ) { ois.readInt(); // method ois.readLong(); // hash System.err.println("Is DGC call for " + Arrays.toString((ObjID[])ois.readObject())); } System.err.println("Sending return with payload for obj " + read); out.writeByte(TransportConstants.Return);// transport op ObjectOutputStream oos = new JRMPClient.MarshalOutputStream(out, this.classpathUrl); oos.writeByte(TransportConstants.ExceptionalReturn); new UID().write(oos); BadAttributeValueExpException ex = new BadAttributeValueExpException(null); Reflections.setFieldValue(ex, "val", payload); oos.writeObject(ex); oos.flush(); out.flush(); this.hadConnection = true; synchronized ( this.waitLock ) { this.waitLock.notifyAll(); } }
Example 19
Source File: Element.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 4 votes |
/** * A helper method that serializes the element object. * * @param stream * the stream to which the element should be serialized. * @throws IOException * if an IO error occured or a property was not serializable. */ private void writeObject( final ObjectOutputStream stream ) throws IOException { stream.defaultWriteObject(); final ReportAttributeMap attributes = this.attributes; stream.writeLong( attributes.getChangeTracker() ); final String[] nameSpaces = attributes.getNameSpaces(); stream.writeObject( nameSpaces ); for ( int i = 0; i < nameSpaces.length; i++ ) { final String nameSpace = nameSpaces[i]; final String[] names = attributes.getNames( nameSpace ); stream.writeObject( names ); for ( int j = 0; j < names.length; j++ ) { final String name = names[j]; final Object attribute = attributes.getAttribute( nameSpace, name ); final AttributeMetaData data = getMetaData().getAttributeDescription( nameSpace, name ); if ( data != null ) { if ( data.isTransient() ) { stream.writeByte( 1 ); continue; } if ( attribute instanceof ResourceKey ) { final ResourceKey key = (ResourceKey) attribute; final ResourceKey parent = key.getParent(); if ( AttributeNames.Core.NAMESPACE.equals( nameSpace ) && ( AttributeNames.Core.CONTENT_BASE.equals( name ) || AttributeNames.Core.SOURCE.equals( name ) ) ) { if ( parent != null ) { // unwrap the content base attribute. After deserialization, the report assumes the bundle-location // as content base, as the bundle will be gone. if ( isKeySerializable( parent ) ) { stream.writeByte( 0 ); SerializerHelper.getInstance().writeObject( parent, stream ); } else { stream.writeByte( 1 ); } } else { // great, the report was never part of a bundle. That makes life easier and the key should be // safely serializable too. if ( isKeySerializable( key ) ) { stream.writeByte( 0 ); SerializerHelper.getInstance().writeObject( key, stream ); } else { stream.writeByte( 1 ); } } } else { if ( "Resource".equals( data.getValueRole() ) || parent != null ) { stream.writeByte( 0 ); try { final ResourceKey resourceKey = ResourceKeyUtils.embedResourceInKey( locateResourceManager(), key, key.getFactoryParameters() ); SerializerHelper.getInstance().writeObject( resourceKey, stream ); } catch ( ResourceException e ) { throw new IOException( "Failed to convert resource-key into byte-array key: " + e ); } } else { stream.writeByte( 0 ); SerializerHelper.getInstance().writeObject( attribute, stream ); } } } else if ( SerializerHelper.getInstance().isSerializable( attribute ) ) { stream.writeByte( 0 ); SerializerHelper.getInstance().writeObject( attribute, stream ); } else { stream.writeByte( 1 ); } } else if ( attribute instanceof String ) { stream.writeByte( 0 ); SerializerHelper.getInstance().writeObject( attribute, stream ); } else { stream.writeByte( 1 ); } } } }
Example 20
Source File: MonitoredNumbersResponse.java From visualvm with GNU General Public License v2.0 | 4 votes |
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); }