當前位置: 首頁>>代碼示例>>Java>>正文


Java ObjectInputStream.readFloat方法代碼示例

本文整理匯總了Java中java.io.ObjectInputStream.readFloat方法的典型用法代碼示例。如果您正苦於以下問題:Java ObjectInputStream.readFloat方法的具體用法?Java ObjectInputStream.readFloat怎麽用?Java ObjectInputStream.readFloat使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.io.ObjectInputStream的用法示例。


在下文中一共展示了ObjectInputStream.readFloat方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: doReadObject

import java.io.ObjectInputStream; //導入方法依賴的package包/類
/**
 * Replaces the superclassm method to read the state of this class.
 * <p>
 * Serialization is not one of the JDK's nicest topics. Normal serialization will
 * initialise the superclass before the subclass. Sometimes however, this isn't
 * what you want, as in this case the <code>put()</code> method on read can be
 * affected by subclass state.
 * <p>
 * The solution adopted here is to deserialize the state data of this class in
 * this protected method. This method must be called by the
 * <code>readObject()</code> of the first serializable subclass.
 * <p>
 * Subclasses may override if the subclass has a specific field that must be present
 * before <code>put()</code> or <code>calculateThreshold()</code> will work correctly.
 * 
 * @param in  the input stream
 */
protected void doReadObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    this.keyType = in.readInt();
    this.valueType = in.readInt();
    this.purgeValues = in.readBoolean();
    this.loadFactor = in.readFloat();
    int capacity = in.readInt();
    init();
    data = new HashEntry[capacity];
    while (true) {
        Object key = in.readObject();
        if (key == null) {
            break;
        }
        Object value = in.readObject();
        put(key, value);
    }
    threshold = calculateThreshold(data.length, loadFactor);
    // do not call super.doReadObject() as code there doesn't work for reference map
}
 
開發者ID:PhilippC,項目名稱:keepass2android,代碼行數:37,代碼來源:AbstractReferenceMap.java

示例2: doReadObject

import java.io.ObjectInputStream; //導入方法依賴的package包/類
/**
 * Replaces the superclass method to read the state of this class.
 * <p>
 * Serialization is not one of the JDK's nicest topics. Normal serialization will
 * initialise the superclass before the subclass. Sometimes however, this isn't
 * what you want, as in this case the <code>put()</code> method on read can be
 * affected by subclass state.
 * <p>
 * The solution adopted here is to deserialize the state data of this class in
 * this protected method. This method must be called by the
 * <code>readObject()</code> of the first serializable subclass.
 * <p>
 * Subclasses may override if the subclass has a specific field that must be present
 * before <code>put()</code> or <code>calculateThreshold()</code> will work correctly.
 *
 * @param in  the input stream
 * @throws IOException if an error occurs while reading from the stream
 * @throws ClassNotFoundException if an object read from the stream can not be loaded
 */
@Override
@SuppressWarnings("unchecked")
protected void doReadObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
    this.keyType = ReferenceStrength.resolve(in.readInt());
    this.valueType = ReferenceStrength.resolve(in.readInt());
    this.purgeValues = in.readBoolean();
    this.loadFactor = in.readFloat();
    final int capacity = in.readInt();
    init();
    data = new HashEntry[capacity];
    while (true) {
        final K key = (K) in.readObject();
        if (key == null) {
            break;
        }
        final V value = (V) in.readObject();
        put(key, value);
    }
    threshold = calculateThreshold(data.length, loadFactor);
    // do not call super.doReadObject() as code there doesn't work for reference map
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:41,代碼來源:AbstractReferenceMap.java

示例3: readObject

import java.io.ObjectInputStream; //導入方法依賴的package包/類
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();
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:17,代碼來源:CustomObjTrees.java

示例4: doReps

import java.io.ObjectInputStream; //導入方法依賴的package包/類
/**
 * 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.writeFloat((float) 0.0);
        }
        oout.flush();
        for (int j = 0; j < ncycles; j++) {
            oin.readFloat();
        }
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:20,代碼來源:Floats.java

示例5: loadLegacyFormat

import java.io.ObjectInputStream; //導入方法依賴的package包/類
/**
 * Loads a legacy configuration file
 * @param saveloc The save location
 * @return Whether or not the config was loaded successfully
 */
@SuppressWarnings("unchecked")
private final boolean loadLegacyFormat(File saveloc){
	try {
		ObjectInputStream objin = new ObjectInputStream(new FileInputStream(saveloc));
		keyinfo = (List<KeyInformation>) objin.readObject();
		showMax = objin.readBoolean();
		showCur = objin.readBoolean();
		showAvg = objin.readBoolean();
		showGraph = objin.readBoolean();
		graphAvg = objin.readBoolean();
		backlog = objin.readInt();
		updateRate = objin.readInt();
		double version = 3.0D;
		if(objin.available() > 0){
			customColors = objin.readBoolean();
			background = (Color)objin.readObject();
			foreground = (Color)objin.readObject();
			if(objin.available() > 0){
				trackAll = objin.readBoolean();
				showKeys = objin.readBoolean();
				if(objin.available() > 0){
					version = objin.readDouble();
				}
			}
		}
		if(version >= 3.9){
			precision = objin.readInt();
		}
		if(version >= 3.10){
			opacitybg = objin.readFloat();
			opacityfg = objin.readFloat();
		}
		if(version >= 4.0D){
			size = objin.readDouble();
		}
		if(version >= 4.2D){
			overlay = objin.readBoolean();
		}
		objin.close();
		for(KeyInformation info : keyinfo){
			if(version < 3.7D){
				info.visible = true;
			}
			if(info.index > KeyInformation.autoIndex){
				KeyInformation.autoIndex = info.index + 1;
			}
		}
		return true;
	} catch (Exception e1) {
		e1.printStackTrace();
		return false;
	}
}
 
開發者ID:RoanH,項目名稱:KeysPerSecond,代碼行數:59,代碼來源:Configuration.java

示例6: doReadObject

import java.io.ObjectInputStream; //導入方法依賴的package包/類
/**
 * Reads the map data from the stream. This method must be overridden if a
 * subclass must be setup before <code>put()</code> is used.
 * <p>
 * Serialization is not one of the JDK's nicest topics. Normal serialization will
 * initialise the superclass before the subclass. Sometimes however, this isn't
 * what you want, as in this case the <code>put()</code> method on read can be
 * affected by subclass state.
 * <p>
 * The solution adopted here is to deserialize the state data of this class in
 * this protected method. This method must be called by the
 * <code>readObject()</code> of the first serializable subclass.
 * <p>
 * Subclasses may override if the subclass has a specific field that must be present
 * before <code>put()</code> or <code>calculateThreshold()</code> will work correctly.
 * 
 * @param in  the input stream
 */
protected void doReadObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    loadFactor = in.readFloat();
    int capacity = in.readInt();
    int size = in.readInt();
    init();
    threshold = calculateThreshold(capacity, loadFactor);
    data = new HashEntry[capacity];
    for (int i = 0; i < size; i++) {
        Object key = in.readObject();
        Object value = in.readObject();
        put(key, value);
    }
}
 
開發者ID:PhilippC,項目名稱:keepass2android,代碼行數:32,代碼來源:AbstractHashedMap.java

示例7: doReadObject

import java.io.ObjectInputStream; //導入方法依賴的package包/類
/**
 * Reads the map data from the stream. This method must be overridden if a
 * subclass must be setup before <code>put()</code> is used.
 * <p>
 * Serialization is not one of the JDK's nicest topics. Normal serialization will
 * initialise the superclass before the subclass. Sometimes however, this isn't
 * what you want, as in this case the <code>put()</code> method on read can be
 * affected by subclass state.
 * <p>
 * The solution adopted here is to deserialize the state data of this class in
 * this protected method. This method must be called by the
 * <code>readObject()</code> of the first serializable subclass.
 * <p>
 * Subclasses may override if the subclass has a specific field that must be present
 * before <code>put()</code> or <code>calculateThreshold()</code> will work correctly.
 *
 * @param in  the input stream
 * @throws IOException if an error occurs while reading from the stream
 * @throws ClassNotFoundException if an object read from the stream can not be loaded
 */
@SuppressWarnings("unchecked")
protected void doReadObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
    loadFactor = in.readFloat();
    final int capacity = in.readInt();
    final int size = in.readInt();
    init();
    threshold = calculateThreshold(capacity, loadFactor);
    data = new HashEntry[capacity];
    for (int i = 0; i < size; i++) {
        final K key = (K) in.readObject();
        final V value = (V) in.readObject();
        put(key, value);
    }
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:35,代碼來源:AbstractHashedMap.java


注:本文中的java.io.ObjectInputStream.readFloat方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。