Java Code Examples for java.io.ObjectOutputStream#writeFloat()

The following examples show how to use java.io.ObjectOutputStream#writeFloat() . 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: Floats.java    From dragonwell8_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.writeFloat((float) 0.0);
        }
        oout.flush();
        for (int j = 0; j < ncycles; j++) {
            oin.readFloat();
        }
    }
}
 
Example 2
Source File: Cfg.java    From screen-dimmer-pixel-filter with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
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
    }
}
 
Example 3
Source File: SerialUtils.java    From orson-charts with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 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);
    }
}
 
Example 4
Source File: GenerationSerializer.java    From myrrix-recommender with Apache License 2.0 6 votes vote down vote up
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);
      }
    }
  }
}
 
Example 5
Source File: Floats.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.writeFloat((float) 0.0);
        }
        oout.flush();
        for (int j = 0; j < ncycles; j++) {
            oin.readFloat();
        }
    }
}
 
Example 6
Source File: GenerationSerializer.java    From myrrix-recommender with Apache License 2.0 6 votes vote down vote up
/**
 * @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);
      }
    }
  }
}
 
Example 7
Source File: Floats.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.writeFloat((float) 0.0);
        }
        oout.flush();
        for (int j = 0; j < ncycles; j++) {
            oin.readFloat();
        }
    }
}
 
Example 8
Source File: BasicStrokeSerializer.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * 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() );
}
 
Example 9
Source File: CustomObjTrees.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example 10
Source File: CustomObjTrees.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example 11
Source File: CustomObjTrees.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example 12
Source File: HashSet.java    From jtransc with Apache License 2.0 5 votes vote down vote up
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);
    }
}
 
Example 13
Source File: CustomObjTrees.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example 14
Source File: CustomObjTrees.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example 15
Source File: CustomObjTrees.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example 16
Source File: GradientPaintSerializer.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * 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() );
}
 
Example 17
Source File: CustomObjTrees.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example 18
Source File: AbstractHashedMap.java    From jphp with Apache License 2.0 3 votes vote down vote up
/**
 * 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());
    }
}
 
Example 19
Source File: AbstractHashMap.java    From weblaf with GNU General Public License v3.0 3 votes vote down vote up
/**
 * 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 () );
    }
}
 
Example 20
Source File: AbstractHashedMap.java    From AndroidPNClient with Apache License 2.0 3 votes vote down vote up
/**
 * 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());
    }
}