本文整理汇总了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
}
示例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
}
示例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();
}
示例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();
}
}
}
示例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;
}
}
示例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);
}
}
示例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);
}
}