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

The following examples show how to use java.io.ObjectInputStream#readFully() . These examples are extracted from open source projects. 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 Project: netbeans   File: ClassLoadedCommand.java    License: Apache License 2.0 6 votes vote down vote up
void readObject(ObjectInputStream in) throws IOException {
    className = in.readUTF();
    thisAndParentLoaderData = new int[3];

    for (int i = 0; i < 3; i++) {
        thisAndParentLoaderData[i] = in.readInt();
    }

    int len = in.readInt();

    if (len == 0) {
        classFileBytes = null;
    } else {
        classFileBytes = new byte[len];
        in.readFully(classFileBytes);
    }

    threadInCallGraph = in.readBoolean();
}
 
Example 2
void readObject(ObjectInputStream in) throws IOException {
    int nClasses = in.readInt();

    if (nClasses == 0) {
        return;
    }

    classBytes = new byte[nClasses][];

    for (int i = 0; i < nClasses; i++) {
        int len = in.readInt();

        if (len > 0) {
            classBytes[i] = new byte[len];
            in.readFully(classBytes[i]);
        }
    }
}
 
Example 3
Source Project: j2objc   File: SimpleTimeZone.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Reconstitute this object from a stream (i.e., deserialize it).
 *
 * We handle both JDK 1.1
 * binary formats and full formats with a packed byte array.
 */
private void readObject(ObjectInputStream stream)
     throws IOException, ClassNotFoundException
{
    stream.defaultReadObject();

    if (serialVersionOnStream < 1) {
        // Fix a bug in the 1.1 SimpleTimeZone code -- namely,
        // startDayOfWeek and endDayOfWeek were usually uninitialized.  We can't do
        // too much, so we assume SUNDAY, which actually works most of the time.
        if (startDayOfWeek == 0) {
            startDayOfWeek = Calendar.SUNDAY;
        }
        if (endDayOfWeek == 0) {
            endDayOfWeek = Calendar.SUNDAY;
        }

        // The variables dstSavings, startMode, and endMode are post-1.1, so they
        // won't be present if we're reading from a 1.1 stream.  Fix them up.
        startMode = endMode = DOW_IN_MONTH_MODE;
        dstSavings = millisPerHour;
    } else {
        // For 1.1.4, in addition to the 3 new instance variables, we also
        // store the actual rules (which have not be made compatible with 1.1)
        // in the optional area.  Read them in here and parse them.
        int length = stream.readInt();
        byte[] rules = new byte[length];
        stream.readFully(rules);
        unpackRules(rules);
    }

    if (serialVersionOnStream >= 2) {
        int[] times = (int[]) stream.readObject();
        unpackTimes(times);
    }

    serialVersionOnStream = currentSerialVersion;
}
 
Example 4
/**
 * Deserialize the {@code CertificateRevokedException} instance.
 */
private void readObject(ObjectInputStream ois)
    throws IOException, ClassNotFoundException {
    // Read in the non-transient fields
    // (revocationDate, reason, authority)
    ois.defaultReadObject();

    // Defensively copy the revocation date
    revocationDate = new Date(revocationDate.getTime());

    // Read in the size (number of mappings) of the extensions map
    // and create the extensions map
    int size = ois.readInt();
    if (size == 0) {
        extensions = Collections.emptyMap();
    } else {
        extensions = new HashMap<String, Extension>(size);
    }

    // Read in the extensions and put the mappings in the extensions map
    for (int i = 0; i < size; i++) {
        String oid = (String) ois.readObject();
        boolean critical = ois.readBoolean();
        int length = ois.readInt();
        byte[] extVal = new byte[length];
        ois.readFully(extVal);
        Extension ext = sun.security.x509.Extension.newExtension
            (new ObjectIdentifier(oid), critical, extVal);
        extensions.put(oid, ext);
    }
}
 
Example 5
Source Project: Flink-CEPplus   File: StateDescriptor.java    License: Apache License 2.0 5 votes vote down vote up
private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
	// read the non-transient fields
	in.defaultReadObject();

	// read the default value field
	boolean hasDefaultValue = in.readBoolean();
	if (hasDefaultValue) {
		TypeSerializer<T> serializer = serializerAtomicReference.get();
		checkNotNull(serializer, "Serializer not initialized.");

		int size = in.readInt();

		byte[] buffer = new byte[size];

		in.readFully(buffer);

		try (ByteArrayInputStream bais = new ByteArrayInputStream(buffer);
				DataInputViewStreamWrapper inView = new DataInputViewStreamWrapper(bais)) {

			defaultValue = serializer.deserialize(inView);
		}
		catch (Exception e) {
			throw new IOException("Unable to deserialize default value.", e);
		}
	} else {
		defaultValue = null;
	}
}
 
Example 6
/**
 * Deserialize the {@code CertificateRevokedException} instance.
 */
private void readObject(ObjectInputStream ois)
    throws IOException, ClassNotFoundException {
    // Read in the non-transient fields
    // (revocationDate, reason, authority)
    ois.defaultReadObject();

    // Defensively copy the revocation date
    revocationDate = new Date(revocationDate.getTime());

    // Read in the size (number of mappings) of the extensions map
    // and create the extensions map
    int size = ois.readInt();
    if (size == 0) {
        extensions = Collections.emptyMap();
    } else {
        extensions = new HashMap<String, Extension>(size);
    }

    // Read in the extensions and put the mappings in the extensions map
    for (int i = 0; i < size; i++) {
        String oid = (String) ois.readObject();
        boolean critical = ois.readBoolean();
        int length = ois.readInt();
        byte[] extVal = new byte[length];
        ois.readFully(extVal);
        Extension ext = sun.security.x509.Extension.newExtension
            (new ObjectIdentifier(oid), critical, extVal);
        extensions.put(oid, ext);
    }
}
 
Example 7
public static void Init(Context ctx) {
    if (Initialized) {
        return;
    }
    try {
        ObjectInputStream in = new ObjectInputStream(ctx.openFileInput(SettingsFileName));
        Pattern = in.readInt();
        ShiftTimeoutIdx = in.readInt();
        UseLightSensor = in.readBoolean();
        LightSensorValue = in.readFloat();
        if (Pattern < 0 || Pattern >= Grids.Patterns.length) {
            Pattern = 3;
        }
        if (ShiftTimeoutIdx < 0 || ShiftTimeoutIdx > Grids.ShiftTimeouts.length) {
            ShiftTimeoutIdx = 4;
        }
        for (int i = Grids.PatternIdCustom; i < Grids.Patterns.length; i++) {
            in.readFully(Grids.Patterns[i]);
        }
        in.readBoolean(); // Not used anymore
        in.readBoolean(); // Not used anymore
        WasEnabled = in.readBoolean();
        SamsungBacklight = in.readBoolean();
        HideNotification = in.readBoolean();
        FirstStart = false;
        PersistentNotification = in.readBoolean();
        in.close();
    } catch (Exception e) {
        Log.d(LOG, "Cannot load config file: " + e); //NON-NLS
    }
    Initialized = true;
}
 
Example 8
/**
 * Reconstitute this object from a stream (i.e., deserialize it).
 *
 * We handle both JDK 1.1
 * binary formats and full formats with a packed byte array.
 */
private void readObject(ObjectInputStream stream)
     throws IOException, ClassNotFoundException
{
    stream.defaultReadObject();

    if (serialVersionOnStream < 1) {
        // Fix a bug in the 1.1 SimpleTimeZone code -- namely,
        // startDayOfWeek and endDayOfWeek were usually uninitialized.  We can't do
        // too much, so we assume SUNDAY, which actually works most of the time.
        if (startDayOfWeek == 0) {
            startDayOfWeek = Calendar.SUNDAY;
        }
        if (endDayOfWeek == 0) {
            endDayOfWeek = Calendar.SUNDAY;
        }

        // The variables dstSavings, startMode, and endMode are post-1.1, so they
        // won't be present if we're reading from a 1.1 stream.  Fix them up.
        startMode = endMode = DOW_IN_MONTH_MODE;
        dstSavings = millisPerHour;
    } else {
        // For 1.1.4, in addition to the 3 new instance variables, we also
        // store the actual rules (which have not be made compatible with 1.1)
        // in the optional area.  Read them in here and parse them.
        int length = stream.readInt();
        byte[] rules = new byte[length];
        stream.readFully(rules);
        unpackRules(rules);
    }

    if (serialVersionOnStream >= 2) {
        int[] times = (int[]) stream.readObject();
        unpackTimes(times);
    }

    serialVersionOnStream = currentSerialVersion;
}
 
Example 9
/**
 * Deserialize the {@code CertificateRevokedException} instance.
 */
private void readObject(ObjectInputStream ois)
    throws IOException, ClassNotFoundException {
    // Read in the non-transient fields
    // (revocationDate, reason, authority)
    ois.defaultReadObject();

    // Defensively copy the revocation date
    revocationDate = new Date(revocationDate.getTime());

    // Read in the size (number of mappings) of the extensions map
    // and create the extensions map
    int size = ois.readInt();
    if (size == 0) {
        extensions = Collections.emptyMap();
    } else {
        extensions = new HashMap<String, Extension>(size);
    }

    // Read in the extensions and put the mappings in the extensions map
    for (int i = 0; i < size; i++) {
        String oid = (String) ois.readObject();
        boolean critical = ois.readBoolean();
        int length = ois.readInt();
        byte[] extVal = new byte[length];
        ois.readFully(extVal);
        Extension ext = sun.security.x509.Extension.newExtension
            (new ObjectIdentifier(oid), critical, extVal);
        extensions.put(oid, ext);
    }
}
 
Example 10
/**
 * Deserialize the {@code CertificateRevokedException} instance.
 */
private void readObject(ObjectInputStream ois)
    throws IOException, ClassNotFoundException {
    // Read in the non-transient fields
    // (revocationDate, reason, authority)
    ois.defaultReadObject();

    // Defensively copy the revocation date
    revocationDate = new Date(revocationDate.getTime());

    // Read in the size (number of mappings) of the extensions map
    // and create the extensions map
    int size = ois.readInt();
    if (size == 0) {
        extensions = Collections.emptyMap();
    } else {
        extensions = new HashMap<String, Extension>(size);
    }

    // Read in the extensions and put the mappings in the extensions map
    for (int i = 0; i < size; i++) {
        String oid = (String) ois.readObject();
        boolean critical = ois.readBoolean();
        int length = ois.readInt();
        byte[] extVal = new byte[length];
        ois.readFully(extVal);
        Extension ext = sun.security.x509.Extension.newExtension
            (new ObjectIdentifier(oid), critical, extVal);
        extensions.put(oid, ext);
    }
}
 
Example 11
Source Project: fluo   File: SimpleConfiguration.java    License: Apache License 2.0 5 votes vote down vote up
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
  in.defaultReadObject();
  init();

  int len = in.readInt();
  byte[] data = new byte[len];
  in.readFully(data);

  ByteArrayInputStream bais = new ByteArrayInputStream(data);
  load(bais);
}
 
Example 12
Source Project: Java8CN   File: SimpleTimeZone.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Reconstitute this object from a stream (i.e., deserialize it).
 *
 * We handle both JDK 1.1
 * binary formats and full formats with a packed byte array.
 */
private void readObject(ObjectInputStream stream)
     throws IOException, ClassNotFoundException
{
    stream.defaultReadObject();

    if (serialVersionOnStream < 1) {
        // Fix a bug in the 1.1 SimpleTimeZone code -- namely,
        // startDayOfWeek and endDayOfWeek were usually uninitialized.  We can't do
        // too much, so we assume SUNDAY, which actually works most of the time.
        if (startDayOfWeek == 0) {
            startDayOfWeek = Calendar.SUNDAY;
        }
        if (endDayOfWeek == 0) {
            endDayOfWeek = Calendar.SUNDAY;
        }

        // The variables dstSavings, startMode, and endMode are post-1.1, so they
        // won't be present if we're reading from a 1.1 stream.  Fix them up.
        startMode = endMode = DOW_IN_MONTH_MODE;
        dstSavings = millisPerHour;
    } else {
        // For 1.1.4, in addition to the 3 new instance variables, we also
        // store the actual rules (which have not be made compatible with 1.1)
        // in the optional area.  Read them in here and parse them.
        int length = stream.readInt();
        byte[] rules = new byte[length];
        stream.readFully(rules);
        unpackRules(rules);
    }

    if (serialVersionOnStream >= 2) {
        int[] times = (int[]) stream.readObject();
        unpackTimes(times);
    }

    serialVersionOnStream = currentSerialVersion;
}
 
Example 13
/**
 * Reconstitute this object from a stream (i.e., deserialize it).
 *
 * We handle both JDK 1.1
 * binary formats and full formats with a packed byte array.
 */
private void readObject(ObjectInputStream stream)
     throws IOException, ClassNotFoundException
{
    stream.defaultReadObject();

    if (serialVersionOnStream < 1) {
        // Fix a bug in the 1.1 SimpleTimeZone code -- namely,
        // startDayOfWeek and endDayOfWeek were usually uninitialized.  We can't do
        // too much, so we assume SUNDAY, which actually works most of the time.
        if (startDayOfWeek == 0) {
            startDayOfWeek = Calendar.SUNDAY;
        }
        if (endDayOfWeek == 0) {
            endDayOfWeek = Calendar.SUNDAY;
        }

        // The variables dstSavings, startMode, and endMode are post-1.1, so they
        // won't be present if we're reading from a 1.1 stream.  Fix them up.
        startMode = endMode = DOW_IN_MONTH_MODE;
        dstSavings = millisPerHour;
    } else {
        // For 1.1.4, in addition to the 3 new instance variables, we also
        // store the actual rules (which have not be made compatible with 1.1)
        // in the optional area.  Read them in here and parse them.
        int length = stream.readInt();
        byte[] rules = new byte[length];
        stream.readFully(rules);
        unpackRules(rules);
    }

    if (serialVersionOnStream >= 2) {
        int[] times = (int[]) stream.readObject();
        unpackTimes(times);
    }

    serialVersionOnStream = currentSerialVersion;
}
 
Example 14
Source Project: geowave   File: KDERunner.java    License: Apache License 2.0 5 votes vote down vote up
private void readObject(final ObjectInputStream aInputStream)
    throws ClassNotFoundException, IOException {
  final byte[] adapterBytes = new byte[aInputStream.readShort()];
  aInputStream.readFully(adapterBytes);
  final byte[] indexBytes = new byte[aInputStream.readShort()];
  aInputStream.readFully(indexBytes);
  newAdapter = (RasterDataAdapter) PersistenceUtils.fromBinary(adapterBytes);
  index = (Index) PersistenceUtils.fromBinary(indexBytes);
  writableSerializer = newAdapter.createWritableSerializer();
}
 
Example 15
/**
 * Deserialize the {@code CertificateRevokedException} instance.
 */
private void readObject(ObjectInputStream ois)
    throws IOException, ClassNotFoundException {
    // Read in the non-transient fields
    // (revocationDate, reason, authority)
    ois.defaultReadObject();

    // Defensively copy the revocation date
    revocationDate = new Date(revocationDate.getTime());

    // Read in the size (number of mappings) of the extensions map
    // and create the extensions map
    int size = ois.readInt();
    if (size == 0) {
        extensions = Collections.emptyMap();
    } else {
        extensions = new HashMap<>(size);
    }

    // Read in the extensions and put the mappings in the extensions map
    for (int i = 0; i < size; i++) {
        String oid = (String) ois.readObject();
        boolean critical = ois.readBoolean();
        int length = ois.readInt();
        byte[] extVal = new byte[length];
        ois.readFully(extVal);
        Extension ext = sun.security.x509.Extension.newExtension
            (new ObjectIdentifier(oid), critical, extVal);
        extensions.put(oid, ext);
    }
}
 
Example 16
/**
 * Reconstitute this object from a stream (i.e., deserialize it).
 *
 * We handle both JDK 1.1
 * binary formats and full formats with a packed byte array.
 */
private void readObject(ObjectInputStream stream)
     throws IOException, ClassNotFoundException
{
    stream.defaultReadObject();

    if (serialVersionOnStream < 1) {
        // Fix a bug in the 1.1 SimpleTimeZone code -- namely,
        // startDayOfWeek and endDayOfWeek were usually uninitialized.  We can't do
        // too much, so we assume SUNDAY, which actually works most of the time.
        if (startDayOfWeek == 0) {
            startDayOfWeek = Calendar.SUNDAY;
        }
        if (endDayOfWeek == 0) {
            endDayOfWeek = Calendar.SUNDAY;
        }

        // The variables dstSavings, startMode, and endMode are post-1.1, so they
        // won't be present if we're reading from a 1.1 stream.  Fix them up.
        startMode = endMode = DOW_IN_MONTH_MODE;
        dstSavings = millisPerHour;
    } else {
        // For 1.1.4, in addition to the 3 new instance variables, we also
        // store the actual rules (which have not be made compatible with 1.1)
        // in the optional area.  Read them in here and parse them.
        int length = stream.readInt();
        if (length <= MAX_RULE_NUM) {
            byte[] rules = new byte[length];
            stream.readFully(rules);
            unpackRules(rules);
        } else {
            throw new InvalidObjectException("Too many rules: " + length);
        }
    }

    if (serialVersionOnStream >= 2) {
        int[] times = (int[]) stream.readObject();
        unpackTimes(times);
    }

    serialVersionOnStream = currentSerialVersion;
}
 
Example 17
Source Project: JDKSourceCode1.8   File: SimpleTimeZone.java    License: MIT License 4 votes vote down vote up
/**
 * Reconstitute this object from a stream (i.e., deserialize it).
 *
 * We handle both JDK 1.1
 * binary formats and full formats with a packed byte array.
 */
private void readObject(ObjectInputStream stream)
     throws IOException, ClassNotFoundException
{
    stream.defaultReadObject();

    if (serialVersionOnStream < 1) {
        // Fix a bug in the 1.1 SimpleTimeZone code -- namely,
        // startDayOfWeek and endDayOfWeek were usually uninitialized.  We can't do
        // too much, so we assume SUNDAY, which actually works most of the time.
        if (startDayOfWeek == 0) {
            startDayOfWeek = Calendar.SUNDAY;
        }
        if (endDayOfWeek == 0) {
            endDayOfWeek = Calendar.SUNDAY;
        }

        // The variables dstSavings, startMode, and endMode are post-1.1, so they
        // won't be present if we're reading from a 1.1 stream.  Fix them up.
        startMode = endMode = DOW_IN_MONTH_MODE;
        dstSavings = millisPerHour;
    } else {
        // For 1.1.4, in addition to the 3 new instance variables, we also
        // store the actual rules (which have not be made compatible with 1.1)
        // in the optional area.  Read them in here and parse them.
        int length = stream.readInt();
        if (length <= MAX_RULE_NUM) {
            byte[] rules = new byte[length];
            stream.readFully(rules);
            unpackRules(rules);
        } else {
            throw new InvalidObjectException("Too many rules: " + length);
        }
    }

    if (serialVersionOnStream >= 2) {
        int[] times = (int[]) stream.readObject();
        unpackTimes(times);
    }

    serialVersionOnStream = currentSerialVersion;
}
 
Example 18
Source Project: jtransc   File: SimpleTimeZone.java    License: Apache License 2.0 4 votes vote down vote up
private void readObject(ObjectInputStream stream) throws IOException,
        ClassNotFoundException {
    ObjectInputStream.GetField fields = stream.readFields();
    rawOffset = fields.get("rawOffset", 0);
    useDaylight = fields.get("useDaylight", false);
    if (useDaylight) {
        endMonth = fields.get("endMonth", 0);
        endTime = fields.get("endTime", 0);
        startMonth = fields.get("startMonth", 0);
        startTime = fields.get("startTime", 0);
        startYear = fields.get("startYear", 0);
    }
    if (fields.get("serialVersionOnStream", 0) == 0) {
        if (useDaylight) {
            startMode = endMode = DOW_IN_MONTH_MODE;
            endDay = fields.get("endDay", 0);
            endDayOfWeek = fields.get("endDayOfWeek", 0) - 1;
            startDay = fields.get("startDay", 0);
            startDayOfWeek = fields.get("startDayOfWeek", 0) - 1;
        }
    } else {
        dstSavings = fields.get("dstSavings", 0);
        if (useDaylight) {
            endMode = fields.get("endMode", 0);
            startMode = fields.get("startMode", 0);
            int length = stream.readInt();
            byte[] values = new byte[length];
            stream.readFully(values);
            if (length >= 4) {
                startDay = values[0];
                startDayOfWeek = values[1];
                if (startMode != DOM_MODE) {
                    startDayOfWeek--;
                }
                endDay = values[2];
                endDayOfWeek = values[3];
                if (endMode != DOM_MODE) {
                    endDayOfWeek--;
                }
            }
        }
    }
}
 
Example 19
void readObject(ObjectInputStream in) throws IOException {
    int len = in.readInt();
    status = new byte[len];
    in.readFully(status);
}
 
Example 20
Source Project: Bytecoder   File: SimpleTimeZone.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Reconstitute this object from a stream (i.e., deserialize it).
 *
 * We handle both JDK 1.1
 * binary formats and full formats with a packed byte array.
 */
@java.io.Serial
private void readObject(ObjectInputStream stream)
     throws IOException, ClassNotFoundException
{
    stream.defaultReadObject();

    if (serialVersionOnStream < 1) {
        // Fix a bug in the 1.1 SimpleTimeZone code -- namely,
        // startDayOfWeek and endDayOfWeek were usually uninitialized.  We can't do
        // too much, so we assume SUNDAY, which actually works most of the time.
        if (startDayOfWeek == 0) {
            startDayOfWeek = Calendar.SUNDAY;
        }
        if (endDayOfWeek == 0) {
            endDayOfWeek = Calendar.SUNDAY;
        }

        // The variables dstSavings, startMode, and endMode are post-1.1, so they
        // won't be present if we're reading from a 1.1 stream.  Fix them up.
        startMode = endMode = DOW_IN_MONTH_MODE;
        dstSavings = millisPerHour;
    } else {
        // For 1.1.4, in addition to the 3 new instance variables, we also
        // store the actual rules (which have not be made compatible with 1.1)
        // in the optional area.  Read them in here and parse them.
        int length = stream.readInt();
        if (length <= MAX_RULE_NUM) {
            byte[] rules = new byte[length];
            stream.readFully(rules);
            unpackRules(rules);
        } else {
            throw new InvalidObjectException("Too many rules: " + length);
        }
    }

    if (serialVersionOnStream >= 2) {
        int[] times = (int[]) stream.readObject();
        unpackTimes(times);
    }

    serialVersionOnStream = currentSerialVersion;
}