java.io.ObjectOutputStream#writeFloat ( )源码实例Demo

下面列出了java.io.ObjectOutputStream#writeFloat ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: dragonwell8_jdk   文件: Floats.java
/**
 * 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();
        }
    }
}
 
源代码2 项目: screen-dimmer-pixel-filter   文件: Cfg.java
public static void Save(Context ctx) {
    if (!Initialized) {
        return;
    }
    try {
        ObjectOutputStream out = new ObjectOutputStream(ctx.openFileOutput(SettingsFileName, Context.MODE_PRIVATE));
        out.writeInt(Pattern);
        out.writeInt(ShiftTimeoutIdx);
        out.writeBoolean(UseLightSensor);
        out.writeFloat(LightSensorValue);
        //Log.d(LOG, "cfg: writing pattern " + Pattern + " ShiftTimeoutIdx " + ShiftTimeoutIdx);
        for (int i = Grids.PatternIdCustom; i < Grids.Patterns.length; i++) {
            out.write(Grids.Patterns[i]);
        }
        out.writeBoolean(true); // Not used anymore
        out.writeBoolean(true); // Not used anymore
        out.writeBoolean(WasEnabled);
        out.writeBoolean(SamsungBacklight);
        out.writeBoolean(HideNotification);
        out.writeBoolean(PersistentNotification);
        out.close();
    } catch (Exception e) {
        Log.e(LOG, "Cannot save config file: " + e); //NON-NLS
    }
}
 
源代码3 项目: jdk8u60   文件: Floats.java
/**
 * 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();
        }
    }
}
 
源代码4 项目: openjdk-jdk8u   文件: Floats.java
/**
 * 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 项目: myrrix-recommender   文件: GenerationSerializer.java
/**
 * @see #readMatrix(ObjectInputStream)
 */
private static void writeMatrix(FastByIDMap<float[]> matrix, ObjectOutputStream out) throws IOException {
  if (matrix == null) {
    out.writeInt(0);
  } else {
    out.writeInt(matrix.size());
    for (FastByIDMap.MapEntry<float[]> entry : matrix.entrySet()) {
      out.writeLong(entry.getKey());
      float[] features = entry.getValue();
      out.writeInt(features.length);
      for (float f : features) {
        Preconditions.checkState(LangUtils.isFinite(f));
        out.writeFloat(f);
      }
    }
  }
}
 
源代码6 项目: myrrix-recommender   文件: GenerationSerializer.java
private static void writeClusters(Collection<IDCluster> clusters, ObjectOutputStream out) throws IOException {
  if (clusters == null) {
    out.writeInt(0);
  } else {
    out.writeInt(clusters.size());
    for (IDCluster cluster : clusters) {
      FastIDSet members = cluster.getMembers();
      out.writeInt(members.size());
      LongPrimitiveIterator it = members.iterator();
      while (it.hasNext()) {
        out.writeLong(it.nextLong());
      }
      float[] centroid = cluster.getCentroid();
      out.writeInt(centroid.length);
      for (float f : centroid) {
        out.writeFloat(f);
      }
    }
  }
}
 
源代码7 项目: orson-charts   文件: SerialUtils.java
/**
 * Serializes a {@code Stroke} object.  This code handles the
 * {@code BasicStroke} class which is the only {@code Stroke}
 * implementation provided by the JDK (and isn't directly
 * {@code Serializable}).
 *
 * @param stroke  the stroke object ({@code null} permitted).
 * @param stream  the output stream ({@code null} not permitted).
 *
 * @throws IOException if there is an I/O error.
 */
public static void writeStroke(Stroke stroke, ObjectOutputStream stream)
        throws IOException {

    Args.nullNotPermitted(stream, "stream");
    if (stroke != null) {
        stream.writeBoolean(false);
        if (stroke instanceof BasicStroke) {
            BasicStroke s = (BasicStroke) stroke;
            stream.writeObject(BasicStroke.class);
            stream.writeFloat(s.getLineWidth());
            stream.writeInt(s.getEndCap());
            stream.writeInt(s.getLineJoin());
            stream.writeFloat(s.getMiterLimit());
            stream.writeObject(s.getDashArray());
            stream.writeFloat(s.getDashPhase());
        } else {
            stream.writeObject(stroke.getClass());
            stream.writeObject(stroke);
        }
    } else {
        stream.writeBoolean(true);
    }
}
 
源代码8 项目: dragonwell8_jdk   文件: CustomObjTrees.java
private void writeObject(ObjectOutputStream out) throws IOException {
    out.writeBoolean(z);
    out.writeByte(b);
    out.writeChar(c);
    out.writeShort(s);
    out.writeInt(i);
    out.writeFloat(f);
    out.writeLong(j);
    out.writeDouble(d);
    out.writeObject(str);
    out.writeObject(parent);
    out.writeObject(left);
    out.writeObject(right);
}
 
源代码9 项目: openjdk-8   文件: CustomObjTrees.java
private void writeObject(ObjectOutputStream out) throws IOException {
    out.writeBoolean(z);
    out.writeByte(b);
    out.writeChar(c);
    out.writeShort(s);
    out.writeInt(i);
    out.writeFloat(f);
    out.writeLong(j);
    out.writeDouble(d);
    out.writeObject(str);
    out.writeObject(parent);
    out.writeObject(left);
    out.writeObject(right);
}
 
/**
 * Writes a serializable object description to the given object output stream.
 *
 * @param o      the to be serialized object.
 * @param stream the outputstream that should receive the object.
 * @throws IOException if an I/O error occured.
 */
public void writeObject( final Object o, final ObjectOutputStream stream ) throws IOException {
  final GradientPaint gp = (GradientPaint) o;
  final Point2D point2D1 = gp.getPoint1();
  stream.writeFloat( (float) point2D1.getX() );
  stream.writeFloat( (float) point2D1.getY() );
  stream.writeObject( gp.getColor1() );
  final Point2D point2D = gp.getPoint2();
  stream.writeFloat( (float) point2D.getX() );
  stream.writeFloat( (float) point2D.getY() );
  stream.writeObject( gp.getColor2() );
  stream.writeBoolean( gp.isCyclic() );
}
 
源代码11 项目: jdk8u-jdk   文件: CustomObjTrees.java
private void writeObject(ObjectOutputStream out) throws IOException {
    out.writeBoolean(z);
    out.writeByte(b);
    out.writeChar(c);
    out.writeShort(s);
    out.writeInt(i);
    out.writeFloat(f);
    out.writeLong(j);
    out.writeDouble(d);
    out.writeObject(str);
    out.writeObject(parent);
    out.writeObject(left);
    out.writeObject(right);
}
 
源代码12 项目: openjdk-jdk8u   文件: CustomObjTrees.java
private void writeObject(ObjectOutputStream out) throws IOException {
    out.writeBoolean(z);
    out.writeByte(b);
    out.writeChar(c);
    out.writeShort(s);
    out.writeInt(i);
    out.writeFloat(f);
    out.writeLong(j);
    out.writeDouble(d);
    out.writeObject(str);
    out.writeObject(parent);
    out.writeObject(left);
    out.writeObject(right);
}
 
源代码13 项目: pentaho-reporting   文件: BasicStrokeSerializer.java
/**
 * Writes a serializable object description to the given object output stream.
 *
 * @param o      the to be serialized object.
 * @param stream the outputstream that should receive the object.
 * @throws IOException if an I/O error occured.
 */
public void writeObject( final Object o, final ObjectOutputStream stream )
  throws IOException {
  final BasicStroke s = (BasicStroke) o;
  stream.writeFloat( s.getLineWidth() );
  stream.writeInt( s.getEndCap() );
  stream.writeInt( s.getLineJoin() );
  stream.writeFloat( s.getMiterLimit() );
  stream.writeObject( s.getDashArray() );
  stream.writeFloat( s.getDashPhase() );
}
 
源代码14 项目: jtransc   文件: HashSet.java
private void writeObject(ObjectOutputStream stream) throws IOException {
    stream.defaultWriteObject();
    stream.writeInt(backingMap.table.length);
    stream.writeFloat(HashMap.DEFAULT_LOAD_FACTOR);
    stream.writeInt(size());
    for (E e : this) {
        stream.writeObject(e);
    }
}
 
源代码15 项目: openjdk-jdk9   文件: CustomObjTrees.java
private void writeObject(ObjectOutputStream out) throws IOException {
    out.writeBoolean(z);
    out.writeByte(b);
    out.writeChar(c);
    out.writeShort(s);
    out.writeInt(i);
    out.writeFloat(f);
    out.writeLong(j);
    out.writeDouble(d);
    out.writeObject(str);
    out.writeObject(parent);
    out.writeObject(left);
    out.writeObject(right);
}
 
源代码16 项目: hottub   文件: CustomObjTrees.java
private void writeObject(ObjectOutputStream out) throws IOException {
    out.writeBoolean(z);
    out.writeByte(b);
    out.writeChar(c);
    out.writeShort(s);
    out.writeInt(i);
    out.writeFloat(f);
    out.writeLong(j);
    out.writeDouble(d);
    out.writeObject(str);
    out.writeObject(parent);
    out.writeObject(left);
    out.writeObject(right);
}
 
源代码17 项目: openjdk-8-source   文件: CustomObjTrees.java
private void writeObject(ObjectOutputStream out) throws IOException {
    out.writeBoolean(z);
    out.writeByte(b);
    out.writeChar(c);
    out.writeShort(s);
    out.writeInt(i);
    out.writeFloat(f);
    out.writeLong(j);
    out.writeDouble(d);
    out.writeObject(str);
    out.writeObject(parent);
    out.writeObject(left);
    out.writeObject(right);
}
 
源代码18 项目: jphp   文件: AbstractHashedMap.java
/**
 * Writes the map data to 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 serialize the state data of this class in
 * this protected method. This method must be called by the
 * <code>writeObject()</code> of the first serializable subclass.
 * <p/>
 * Subclasses may override if they have a specific field that must be present
 * on read before this implementation will work. Generally, the read determines
 * what must be serialized here, if anything.
 *
 * @param out the output stream
 */
protected void doWriteObject(ObjectOutputStream out) throws IOException {
    out.writeFloat(loadFactor);
    out.writeInt(data.length);
    out.writeInt(size);
    for (MapIterator it = mapIterator(); it.hasNext();) {
        out.writeObject(it.next());
        out.writeObject(it.getValue());
    }
}
 
源代码19 项目: weblaf   文件: AbstractHashMap.java
/**
 * Writes the map data to the stream. This method must be overridden if a
 * subclass must be setup before {@code put()} 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()} method on read can be
 * affected by subclass state.
 * <p>
 * The solution adopted here is to serialize the state data of this class in
 * this protected method. This method must be called by the
 * {@code writeObject()} of the first serializable subclass.
 * <p>
 * Subclasses may override if they have a specific field that must be present
 * on read before this implementation will work. Generally, the read determines
 * what must be serialized here, if anything.
 *
 * @param out the output stream
 * @throws IOException if IO operation fails
 */
@SuppressWarnings ( "NonSerializableObjectPassedToObjectStream" )
protected void doWriteObject ( final ObjectOutputStream out ) throws IOException
{
    out.writeFloat ( loadFactor );
    out.writeInt ( data.length );
    out.writeInt ( size );
    for ( final MapIterator<K, V> it = mapIterator (); it.hasNext (); )
    {
        out.writeObject ( it.next () );
        out.writeObject ( it.getValue () );
    }
}
 
源代码20 项目: AndroidPNClient   文件: AbstractHashedMap.java
/**
 * Writes the map data to 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 serialize the state data of this class in
 * this protected method. This method must be called by the
 * <code>writeObject()</code> of the first serializable subclass.
 * <p/>
 * Subclasses may override if they have a specific field that must be present
 * on read before this implementation will work. Generally, the read determines
 * what must be serialized here, if anything.
 *
 * @param out the output stream
 */
protected void doWriteObject(ObjectOutputStream out) throws IOException {
    out.writeFloat(loadFactor);
    out.writeInt(data.length);
    out.writeInt(size);
    for (MapIterator it = mapIterator(); it.hasNext();) {
        out.writeObject(it.next());
        out.writeObject(it.getValue());
    }
}