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

The following examples show how to use java.io.ObjectInputStream#readLong() . 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: CustomObjTrees.java    From openjdk-8-source 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 2
Source File: SerializableCookie.java    From okhttp-OkGo with Apache License 2.0 6 votes vote down vote up
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    in.defaultReadObject();
    String name = (String) in.readObject();
    String value = (String) in.readObject();
    long expiresAt = in.readLong();
    String domain = (String) in.readObject();
    String path = (String) in.readObject();
    boolean secure = in.readBoolean();
    boolean httpOnly = in.readBoolean();
    boolean hostOnly = in.readBoolean();
    boolean persistent = in.readBoolean();
    Cookie.Builder builder = new Cookie.Builder();
    builder = builder.name(name);
    builder = builder.value(value);
    builder = builder.expiresAt(expiresAt);
    builder = hostOnly ? builder.hostOnlyDomain(domain) : builder.domain(domain);
    builder = builder.path(path);
    builder = secure ? builder.secure() : builder;
    builder = httpOnly ? builder.httpOnly() : builder;
    clientCookie = builder.build();
}
 
Example 3
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 4
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 5
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 6
Source File: MappedArrayOfZonedDateTimes.java    From morpheus-core with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
/** Custom serialization */
private void readObject(ObjectInputStream is) throws IOException, ClassNotFoundException {
    this.file = MappedArrayConstructor.randomFile(true);
    this.length = is.readInt();
    this.defaultValueAsLong = is.readLong();
    this.defaultZoneId = is.readShort();
    this.defaultValue = (ZonedDateTime)is.readObject();
    this.channel = new RandomAccessFile(file, "rw").getChannel();
    this.byteBuffer = channel.map(FileChannel.MapMode.READ_WRITE, 0, BYTE_COUNT * length);
    for (int i=0; i<length; ++i) {
        final int byteIndex = i * BYTE_COUNT;
        final long epochMillis = is.readLong();
        final short zoneId = is.readShort();
        this.byteBuffer.putLong(byteIndex, epochMillis);
        this.byteBuffer.putShort(byteIndex + 8, zoneId);
    }
}
 
Example 7
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 8
Source File: Longs.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.writeLong(0);
        }
        oout.flush();
        for (int j = 0; j < ncycles; j++) {
            oin.readLong();
        }
    }
}
 
Example 9
Source File: SerializableOkHttpCookies.java    From chaoli-forum-for-android-2 with GNU General Public License v3.0 6 votes vote down vote up
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    String name = (String) in.readObject();
    String value = (String) in.readObject();
    long expiresAt = in.readLong();
    String domain = (String) in.readObject();
    String path = (String) in.readObject();
    boolean secure = in.readBoolean();
    boolean httpOnly = in.readBoolean();
    boolean hostOnly = in.readBoolean();
    boolean persistent = in.readBoolean();
    Cookie.Builder builder = new Cookie.Builder();
    builder = builder.name(name);
    builder = builder.value(value);
    builder = builder.expiresAt(expiresAt);
    builder = hostOnly ? builder.hostOnlyDomain(domain) : builder.domain(domain);
    builder = builder.path(path);
    builder = secure ? builder.secure() : builder;
    builder = httpOnly ? builder.httpOnly() : builder;
    clientCookies =builder.build();
}
 
Example 10
Source File: Longs.java    From openjdk-jdk8u 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.writeLong(0);
        }
        oout.flush();
        for (int j = 0; j < ncycles; j++) {
            oin.readLong();
        }
    }
}
 
Example 11
Source File: Longs.java    From jdk8u60 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.writeLong(0);
        }
        oout.flush();
        for (int j = 0; j < ncycles; j++) {
            oin.readLong();
        }
    }
}
 
Example 12
Source File: IntArray.java    From rtg-tools with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Should only be called from {@link IntCreate#loadIndex(java.io.ObjectInputStream)}
 * @param ois stream to load from
 * @return index loaded from stream
 * @throws IOException if an IO error occurs
 */
public static IntArray loadIndex(ObjectInputStream ois) throws IOException {
  final long length = ois.readLong();
  final int[] data;
  try {
    data = (int[]) ois.readObject();
  } catch (ClassNotFoundException e) {
    throw new IOException("Unrecognized index type", e);
  }
  return new IntArray(data, length);
}
 
Example 13
Source File: TLongHashSet.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
private void readObject(ObjectInputStream stream)
    throws IOException, ClassNotFoundException {
    stream.defaultReadObject();

    int size = stream.readInt();
    setUp(size);
    while (size-- > 0) {
        long val = stream.readLong();
        add(val);
    }
}
 
Example 14
Source File: InputStreamMarkResetTest.java    From kogito-runtimes with Apache License 2.0 5 votes vote down vote up
@Test
public void basicReadAndWriteObjectTest() throws Exception { 

    DataObject thingy = new DataObject();
    thingy.type = 'a';
    thingy.time = new Date().getTime();
    thingy.strCount = "1";

    byte [] bytes = marshallThingy(thingy);

    
    ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
    BufferedInputStream bis = new BufferedInputStream(bais);
    ObjectInputStream stream = new ObjectInputStream(bis);

    DataObject unmaThingy = new DataObject();
    unmaThingy.type = stream.readChar();
    unmaThingy.time = stream.readLong();
    
    assertTrue( bis.markSupported(), "Mark/reset is not supported" );
    bis.mark(8);
    int [] intBytes = new int [4];
    intBytes[0] = bis.read();
    intBytes[1] = bis.read();
    intBytes[2] = bis.read();
    intBytes[3] = bis.read();
    if ((intBytes[0] | intBytes[1] | intBytes[2] | intBytes[3] ) < 0) { 
        bis.reset();
    }
    unmaThingy.strCount = stream.readUTF();

    assertTrue( thingy.equals(unmaThingy) );
}
 
Example 15
Source File: LongObjectHashMap.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
private void readObject(ObjectInputStream inputStream) throws ClassNotFoundException, IOException {
    inputStream.defaultReadObject();
    initialize();

    while (true) {
        long key = inputStream.readLong();
        V value = (V) inputStream.readObject();
        if (key == EMPTY_KEY && value == null) {
            break;
        }

        put(key, value);
    }
}
 
Example 16
Source File: WrappedGorillaCompressor.java    From timely with Apache License 2.0 5 votes vote down vote up
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    closed = true;
    numEntries = in.readLong();
    oldestTimestamp = in.readLong();
    newestTimestamp = in.readLong();
    int length = in.readInt();
    backingArray = new long[length];
    for (int x = 0; x < length; x++) {
        backingArray[x] = in.readLong();
    }
}
 
Example 17
Source File: TLongDoubleHashMap.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
private void readObject(ObjectInputStream stream)
    throws IOException, ClassNotFoundException {
    stream.defaultReadObject();

    int size = stream.readInt();
    setUp(size);
    while (size-- > 0) {
        long key = stream.readLong();
        double val = stream.readDouble();
        put(key, val);
    }
}
 
Example 18
Source File: Date.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Reconstitute this object from a stream (i.e., deserialize it).
 */
private void readObject(ObjectInputStream s)
     throws IOException, ClassNotFoundException
{
    fastTime = s.readLong();
}
 
Example 19
Source File: MonitoredNumbersResponse.java    From netbeans with Apache License 2.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: Date.java    From Java8CN with Apache License 2.0 4 votes vote down vote up
/**
 * Reconstitute this object from a stream (i.e., deserialize it).
 */
private void readObject(ObjectInputStream s)
     throws IOException, ClassNotFoundException
{
    fastTime = s.readLong();
}