Java Code Examples for java.io.ObjectInputStream#readByte()

The following examples show how to use java.io.ObjectInputStream#readByte() . 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: SerializerHelper.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Reads the object from the object input stream. This object selects the best serializer to read the object.
 * <p/>
 * Make sure, that you use the same configuration (library and class versions, registered methods in the
 * SerializerHelper) for reading as you used for writing.
 *
 * @param in the object input stream from where to read the serialized data.
 * @return the generated object.
 * @throws IOException            if reading the stream failed.
 * @throws ClassNotFoundException if serialized object class cannot be found.
 */
public synchronized Object readObject( final ObjectInputStream in )
  throws IOException, ClassNotFoundException {
  final int type = in.readByte();
  if ( type == 0 ) {
    return null;
  }
  if ( type == 1 ) {
    return in.readObject();
  }
  final Class c = (Class) in.readObject();
  final SerializeMethod m = getSerializer( c );
  if ( m == null ) {
    throw new NotSerializableException( c.getName() );
  }
  return m.readObject( in );
}
 
Example 2
Source File: CustomObjTrees.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
private void readObject(ObjectInputStream in)
    throws IOException, ClassNotFoundException
{
    z = in.readBoolean();
    b = in.readByte();
    c = in.readChar();
    s = in.readShort();
    i = in.readInt();
    f = in.readFloat();
    j = in.readLong();
    d = in.readDouble();
    str = (String) in.readObject();
    parent = in.readObject();
    left = in.readObject();
    right = in.readObject();
}
 
Example 3
Source File: Element.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * A helper method that deserializes a object from the given stream.
 *
 * @param stream
 *          the stream from which to read the object data.
 * @throws IOException
 *           if an IO error occured.
 * @throws ClassNotFoundException
 *           if an referenced class cannot be found.
 */
private void readObject( final ObjectInputStream stream ) throws IOException, ClassNotFoundException {
  stream.defaultReadObject();
  this.attributes = new ReportAttributeMap<Object>( stream.readLong() );
  final String[] nameSpaces = (String[]) stream.readObject();
  for ( int i = 0; i < nameSpaces.length; i++ ) {
    final String nameSpace = nameSpaces[i];
    final String[] names = (String[]) stream.readObject();
    for ( int j = 0; j < names.length; j++ ) {
      final String name = names[j];
      final int nullHandler = stream.readByte();
      if ( nullHandler == 0 ) {
        final Object attribute = SerializerHelper.getInstance().readObject( stream );
        this.attributes.setAttribute( nameSpace, name, attribute );
      }
    }
  }
}
 
Example 4
Source File: Bytes.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 5
Source File: Bytes.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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: CustomObjTrees.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
private void readObject(ObjectInputStream in)
    throws IOException, ClassNotFoundException
{
    z = in.readBoolean();
    b = in.readByte();
    c = in.readChar();
    s = in.readShort();
    i = in.readInt();
    f = in.readFloat();
    j = in.readLong();
    d = in.readDouble();
    str = (String) in.readObject();
    parent = in.readObject();
    left = in.readObject();
    right = in.readObject();
}
 
Example 7
Source File: CustomObjTrees.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private void readObject(ObjectInputStream in)
    throws IOException, ClassNotFoundException
{
    z = in.readBoolean();
    b = in.readByte();
    c = in.readChar();
    s = in.readShort();
    i = in.readInt();
    f = in.readFloat();
    j = in.readLong();
    d = in.readDouble();
    str = (String) in.readObject();
    parent = in.readObject();
    left = in.readObject();
    right = in.readObject();
}
 
Example 8
Source File: Bytes.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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: CustomObjTrees.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private void readObject(ObjectInputStream in)
    throws IOException, ClassNotFoundException
{
    z = in.readBoolean();
    b = in.readByte();
    c = in.readChar();
    s = in.readShort();
    i = in.readInt();
    f = in.readFloat();
    j = in.readLong();
    d = in.readDouble();
    str = (String) in.readObject();
    parent = in.readObject();
    left = in.readObject();
    right = in.readObject();
}
 
Example 10
Source File: CustomObjTrees.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
private void readObject(ObjectInputStream in)
    throws IOException, ClassNotFoundException
{
    z = in.readBoolean();
    b = in.readByte();
    c = in.readChar();
    s = in.readShort();
    i = in.readInt();
    f = in.readFloat();
    j = in.readLong();
    d = in.readDouble();
    str = (String) in.readObject();
    parent = in.readObject();
    left = in.readObject();
    right = in.readObject();
}
 
Example 11
Source File: CustomObjTrees.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private void readObject(ObjectInputStream in)
    throws IOException, ClassNotFoundException
{
    z = in.readBoolean();
    b = in.readByte();
    c = in.readChar();
    s = in.readShort();
    i = in.readInt();
    f = in.readFloat();
    j = in.readLong();
    d = in.readDouble();
    str = (String) in.readObject();
    parent = in.readObject();
    left = in.readObject();
    right = in.readObject();
}
 
Example 12
Source File: Bytes.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 13
Source File: Bytes.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 14
Source File: CustomObjTrees.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
private void readObject(ObjectInputStream in)
    throws IOException, ClassNotFoundException
{
    z = in.readBoolean();
    b = in.readByte();
    c = in.readChar();
    s = in.readShort();
    i = in.readInt();
    f = in.readFloat();
    j = in.readLong();
    d = in.readDouble();
    str = (String) in.readObject();
    parent = in.readObject();
    left = in.readObject();
    right = in.readObject();
}
 
Example 15
Source File: Bytes.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 16
Source File: MemberBox.java    From openbd-core with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Reads an array of parameter types from the stream.
 */
private static Class<?>[] readParameters(ObjectInputStream in)
    throws IOException, ClassNotFoundException
{
    Class<?>[] result = new Class[in.readShort()];
    for (int i=0; i < result.length; i++) {
        if (!in.readBoolean()) {
            result[i] = (Class<?>) in.readObject();
            continue;
        }
        result[i] = primitives[in.readByte()];
    }
    return result;
}
 
Example 17
Source File: Server.java    From cache2k with Apache License 2.0 5 votes vote down vote up
/**
       * The connections are closed by the server upon receiving the closed operation.
       * We need to block in the client until the server performed the close, to make
       * sure the server has removed the client from the client collection map.
       *
       * <p>This is executed in the client after the close command is sent.
       *
       * @see Client#invoke(Operation)
       */
        public Void onInvoke(final ObjectInputStream ois, final ObjectOutputStream oos) throws IOException {
            try {
                ois.readByte();
                throw new IOException("Unexpected data received from the server after close.");
            } catch (EOFException expected) {
                // connection successfully closed by the server
            }
            return null;
        }
 
Example 18
Source File: ServerDataBox.java    From sofa-registry with Apache License 2.0 4 votes vote down vote up
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    serialization = in.readByte(); // Read serialization type
    int size = in.readInt(); // Read byte stream size
    bytes = new byte[size];
    in.readFully(bytes); // Read the byte stream
}
 
Example 19
Source File: MonitoredNumbersResponse.java    From visualvm with GNU General Public License v2.0 4 votes vote down vote up
void readObject(ObjectInputStream in) throws IOException {
    int arrSize;

    mode = in.readInt();
    for (int i = 0; i < generalNumbers.length; i++) {
        generalNumbers[i] = in.readLong();
    }

    if (mode == CommonConstants.MODE_THREADS_SAMPLING) {
        nThreads = in.readInt();
        nThreadStates = in.readInt();
        if (threadIds.length < nThreads) {
            threadIds = new int[nThreads];
        }
        if (stateTimestamps.length < nThreadStates) {
            stateTimestamps = new long[nThreadStates];
        }
        
        int len = nThreads * nThreadStates;
        
        if (threadStates.length < len) {
            threadStates = new byte[len];
        }
        for (int i = 0; i < nThreads; i++) {
            threadIds[i] = in.readInt();
        }
        for (int i = 0; i < nThreadStates; i++) {
            stateTimestamps[i] = in.readLong();
        }
        in.readFully(threadStates, 0, len);
    }  else if (mode == CommonConstants.MODE_THREADS_EXACT) {
        int exactLen = in.readInt();
        exactThreadIds = new int[exactLen];
        exactThreadStates = new byte[exactLen];
        exactTimeStamps = new long[exactLen];
        
        for (int i = 0; i < exactLen; i++) {
            exactThreadIds[i] = in.readInt();
            exactThreadStates[i] = in.readByte();
            exactTimeStamps[i] = in.readLong();
        }
    }

    nNewThreads = in.readInt();

    if (nNewThreads > 0) {
        if ((newThreadIds == null) || (newThreadIds.length < nNewThreads)) {
            newThreadIds = new int[nNewThreads];
            newThreadNames = new String[nNewThreads];
            newThreadClassNames = new String[nNewThreads];
        }

        for (int i = 0; i < nNewThreads; i++) {
            newThreadIds[i] = in.readInt();
            newThreadNames[i] = in.readUTF();
            newThreadClassNames[i] = in.readUTF();
        }
    }

    arrSize = in.readInt();
    gcStarts = new long[arrSize];

    for (int i = 0; i < arrSize; i++) {
        gcStarts[i] = in.readLong();
    }

    arrSize = in.readInt();
    gcFinishs = new long[arrSize];

    for (int i = 0; i < arrSize; i++) {
        gcFinishs[i] = in.readLong();
    }

    Arrays.sort(gcStarts);
    Arrays.sort(gcFinishs);

    serverState = in.readInt();
    serverProgress = in.readInt();
}
 
Example 20
Source File: Molecule.java    From openchemlib-js with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private void readObject(ObjectInputStream stream) throws IOException {
mAllAtoms = stream.readInt();
mAllBonds = stream.readInt();

mMaxAtoms = mAllAtoms;
mMaxBonds = mAllBonds;
init();

mIsFragment = stream.readBoolean();

for (int atom=0; atom<mAllAtoms; atom++) {
	mAtomicNo[atom] = stream.readInt();
	mAtomCharge[atom] = stream.readInt();
	mAtomMass[atom] = stream.readInt();
	mAtomFlags[atom] = stream.readInt();
	mAtomQueryFeatures[atom] = stream.readInt();
	mCoordinates[atom].set(stream.readDouble(), stream.readDouble(), stream.readDouble());
	mAtomMapNo[atom] = stream.readInt();

	int count = stream.readInt();
	if (count != 0) {
		if (mAtomList == null)
			mAtomList = new int[mMaxAtoms][];
		mAtomList[atom] = new int[count];
		for (int i=0; i<count; i++)
			mAtomList[atom][i] = stream.readInt();
		}

	count = stream.readInt();
	if (count != 0) {
		if (mAtomCustomLabel == null)
			mAtomCustomLabel = new byte[mMaxAtoms][];
		mAtomCustomLabel[atom] = new byte[count];
		for (int i=0; i<count; i++)
			mAtomCustomLabel[atom][i] = stream.readByte();
		}
	}

for (int bond=0; bond<mAllBonds; bond++) {
	mBondAtom[0][bond] = stream.readInt();
	mBondAtom[1][bond] = stream.readInt();
	mBondType[bond] = stream.readInt();
	mBondFlags[bond] = stream.readInt();
	mBondQueryFeatures[bond] = stream.readInt();
	}

try {
	mName = (String) stream.readObject();
	} catch(Exception e) {}

mValidHelperArrays = cHelperNone;
}