Java Code Examples for java.io.ObjectOutputStream.writeInt()

The following are Jave code examples for showing how to use writeInt() of the java.io.ObjectOutputStream class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: jrpip   File: ThankYouWriter.java   View Source Code Vote up 5 votes
@Override
public void writeParameters(ObjectOutputStream objectOutputStream) throws IOException
{
    objectOutputStream.writeInt(this.requestList.size());
    for (Object aRequestList : this.requestList)
    {
        //if (CAUSE_RANDOM_ERROR) if (Math.random() > ERROR_RATE) throw new IOException("Random error, for testing only!");
        objectOutputStream.writeObject(aRequestList);
    }
}
 
Example 2
Project: morpheus-core   File: MappedArrayOfInts.java   View Source Code Vote up 5 votes
/** Custom serialization */
private void writeObject(ObjectOutputStream os) throws IOException {
    os.writeInt(length);
    os.writeInt(defaultValue);
    for (int i=0; i<length; ++i) {
        final int value = getInt(i);
        os.writeInt(value);
    }
}
 
Example 3
Project: googles-monorepo-demo   File: LinkedListMultimap.java   View Source Code Vote up 5 votes
/**
 * @serialData the number of distinct keys, and then for each distinct key:
 *     the first key, the number of values for that key, and the key's values,
 *     followed by successive keys and values from the entries() ordering
 */
@GwtIncompatible // java.io.ObjectOutputStream
private void writeObject(ObjectOutputStream stream) throws IOException {
  stream.defaultWriteObject();
  stream.writeInt(size());
  for (Entry<K, V> entry : entries()) {
    stream.writeObject(entry.getKey());
    stream.writeObject(entry.getValue());
  }
}
 
Example 4
Project: fitnotifications   File: SimpleDateFormat.java   View Source Code Vote up 5 votes
/**
 * Override writeObject.
 * See http://docs.oracle.com/javase/6/docs/api/java/io/ObjectOutputStream.html
 */
private void writeObject(ObjectOutputStream stream) throws IOException{
    if (defaultCenturyStart == null) {
        // if defaultCenturyStart is not yet initialized,
        // calculate and set value before serialization.
        initializeDefaultCenturyStart(defaultCenturyBase);
    }
    initializeTimeZoneFormat(false);
    stream.defaultWriteObject();
    stream.writeInt(getContext(DisplayContext.Type.CAPITALIZATION).value());
}
 
Example 5
Project: rapidminer   File: SVMExamples.java   View Source Code Vote up 5 votes
/** Writes the example set into the given output stream. */
public void writeSupportVectors(ObjectOutputStream out) throws IOException {
	out.writeInt(getNumberOfSupportVectors());
	out.writeDouble(b);
	out.writeInt(dim);
	if ((meanVarianceMap == null) || (meanVarianceMap.size() == 0)) {
		out.writeUTF("noscale");
	} else {
		out.writeUTF("scale");
		out.writeInt(meanVarianceMap.size());
		Iterator i = meanVarianceMap.keySet().iterator();
		while (i.hasNext()) {
			Integer index = (Integer) i.next();
			MeanVariance meanVariance = meanVarianceMap.get(index);
			out.writeInt(index.intValue());
			out.writeDouble(meanVariance.getMean());
			out.writeDouble(meanVariance.getVariance());
		}
	}
	for (int e = 0; e < train_size; e++) {
		if (alphas[e] != 0.0d) {
			out.writeInt(atts[e].length);
			for (int a = 0; a < atts[e].length; a++) {
				out.writeInt(index[e][a]);
				out.writeDouble(atts[e][a]);
			}
			out.writeDouble(alphas[e]);
			out.writeDouble(ys[e]);
		}
	}
}
 
Example 6
Project: bitnym   File: ProofMessage.java   View Source Code Vote up 5 votes
private void writeObject(ObjectOutputStream oos)
		throws IOException {
		    //List<byte[]> txs = new ArrayList<byte[]>();
		    //List<Integer> intList = new ArrayList<Integer>();
	System.out.println("serialize proof message, appearedinchainheight is " + this.appearedInChainheight);
	oos.writeInt(appearedInChainheight);
	oos.writeObject(sp);
	for(Integer i : this.outputIndices) {
		oos.writeObject(i);
	}
	for(Transaction tx : this.validationPath) {
		oos.writeObject(tx.bitcoinSerialize());
	}

}
 
Example 7
Project: graphflow   File: EdgeStore.java   View Source Code Vote up 5 votes
@Override
public void serializeMainFile(ObjectOutputStream objectOutputStream) throws IOException {
    objectOutputStream.writeInt(data.length);
    objectOutputStream.writeLong(nextIDNeverYetAssigned);
    objectOutputStream.writeByte(nextBucketOffset);
    objectOutputStream.writeInt(nextBucketId);
    objectOutputStream.writeInt(nextPartitionId);
    objectOutputStream.writeInt(recycledIdsSize);
    objectOutputStream.writeObject(recycledIds);
}
 
Example 8
Project: KeysPerSecond   File: Main.java   View Source Code Vote up 5 votes
/**
 * Saves the statistics logged so far
 */
protected static void saveStats(){
	JFileChooser chooser = new JFileChooser();
	chooser.setFileFilter(new FileNameExtensionFilter("Keys per second statistics file", "kpsstats"));
	chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
	if(chooser.showSaveDialog(null) != JFileChooser.APPROVE_OPTION){
		return;
	}
	File file = new File(chooser.getSelectedFile().getAbsolutePath().endsWith(".kpsstats") ? chooser.getSelectedFile().getAbsolutePath() : (chooser.getSelectedFile().getAbsolutePath() + ".kpsstats"));
	if(!file.exists() || (file.exists() && JOptionPane.showConfirmDialog(null, "File already exists, overwrite?", "Keys per second", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION)){
		try {
			file.createNewFile();
			ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(file));
			out.writeInt(TotPanel.hits);
			out.writeDouble(avg);
			out.writeInt(max);
			out.writeLong(n);
			out.writeInt(prev);
			out.writeInt(tmp.get());
			for(Entry<Integer, Key> key : keys.entrySet()){
				out.writeInt(key.getKey());
				out.writeObject(key.getValue());
			}
			out.flush();
			out.close();
			JOptionPane.showMessageDialog(null, "Statistics succesfully saved", "Keys per second", JOptionPane.INFORMATION_MESSAGE);
		} catch (IOException e) {e.printStackTrace();
		JOptionPane.showMessageDialog(null, "Failed to save the statistics!", "Keys per second", JOptionPane.ERROR_MESSAGE);
		}
	}
}
 
Example 9
Project: morpheus-core   File: DenseArrayOfZonedDateTimes.java   View Source Code Vote up 5 votes
/** Custom serialization */
private void writeObject(ObjectOutputStream os) throws IOException {
    final int length = values.length;
    os.writeInt(length);
    os.writeLong(defaultValueAsLong);
    os.writeObject(defaultValue);
    for (int i=0; i<length; ++i) {
        os.writeLong(values[i]);
        os.writeShort(zoneIds[i]);
    }
}
 
Example 10
Project: incubator-netbeans   File: SetChangeableInstrParamsCommand.java   View Source Code Vote up 5 votes
void writeObject(ObjectOutputStream out) throws IOException {
    out.writeBoolean(lockContentionMonitoringEnabled);
    out.writeInt(nProfiledThreadsLimit);
    out.writeInt(stackDepthLimit);
    out.writeInt(samplingInterval);
    out.writeInt(objAllocStackSamplingInterval);
    out.writeInt(objAllocStackSamplingDepth);
    out.writeBoolean(runGCOnGetResultsInMemoryProfiling);
    out.writeBoolean(waitTrackingEnabled);
    out.writeBoolean(sleepTrackingEnabled);
    out.writeBoolean(threadsSamplingEnabled);
    out.writeInt(threadsSamplingFrequency);
}
 
Example 11
Project: incubator-netbeans   File: InitiateProfilingCommand.java   View Source Code Vote up 5 votes
void writeObject(ObjectOutputStream out) throws IOException {
    out.writeInt(instrType);
    out.writeInt(classNames.length);

    for (int i = 0; i < classNames.length; i++) {
        out.writeUTF(classNames[i]);
    }

    out.writeBoolean(instrSpawnedThreads);
    out.writeBoolean(startProfilingPointsActive);
    out.writeObject(profilingPointIDs);
    out.writeObject(profilingPointHandlers);
    out.writeObject(profilingPointInfos);
}
 
Example 12
Project: sstore-soft   File: MapMakerInternalMap.java   View Source Code Vote up 5 votes
void writeMapTo(ObjectOutputStream out) throws IOException {
  out.writeInt(delegate.size());
  for (Entry<K, V> entry : delegate.entrySet()) {
    out.writeObject(entry.getKey());
    out.writeObject(entry.getValue());
  }
  out.writeObject(null); // terminate entries
}
 
Example 13
Project: openjdk-jdk10   File: StubIORImpl.java   View Source Code Vote up 5 votes
public  void doWrite( ObjectOutputStream stream )
    throws IOException
{
    // write the IOR to the ObjectOutputStream
    stream.writeInt(typeData.length);
    stream.write(typeData);
    stream.writeInt(profileTags.length);
    for (int i = 0; i < profileTags.length; i++) {
        stream.writeInt(profileTags[i]);
        stream.writeInt(profileData[i].length);
        stream.write(profileData[i]);
    }
}
 
Example 14
Project: morpheus-core   File: SparseArrayWithIntCoding.java   View Source Code Vote up 5 votes
@Override
public final void write(ObjectOutputStream os, int[] indexes) throws IOException {
    for (int index : indexes) {
        final int value = getInt(index);
        os.writeInt(value);
    }
}
 
Example 15
Project: parabuild-ci   File: PaintMap.java   View Source Code Vote up 5 votes
/**
 * Provides serialization support.
 *
 * @param stream  the output stream.
 *
 * @throws IOException  if there is an I/O error.
 */
private void writeObject(ObjectOutputStream stream) throws IOException {
    stream.defaultWriteObject();
    stream.writeInt(this.store.size());
    Set keys = this.store.keySet();
    Iterator iterator = keys.iterator();
    while (iterator.hasNext()) {
        Comparable key = (Comparable) iterator.next();
        stream.writeObject(key);
        Paint paint = getPaint(key);
        SerialUtilities.writePaint(paint, stream);
    }
}
 
Example 16
Project: incubator-netbeans   File: GetClassIdCommand.java   View Source Code Vote up 4 votes
void writeObject(ObjectOutputStream out) throws IOException {
    out.writeUTF(className);
    out.writeInt(classLoaderId);
}
 
Example 17
Project: boohee_v5.6   File: ByteString.java   View Source Code Vote up 4 votes
private void writeObject(ObjectOutputStream out) throws IOException {
    out.writeInt(this.data.length);
    out.write(this.data);
}
 
Example 18
Project: openjdk-jdk10   File: ImmutableCollections.java   View Source Code Vote up 3 votes
/**
 * Writes objects to the stream from
 * the transient {@code Object[] array} field.
 *
 * @serialData
 * A nonnegative int, indicating the count of objects,
 * followed by that many objects.
 *
 * @param oos the ObjectOutputStream to which data is written
 * @throws IOException if an I/O error occurs
 * @since 9
 */
private void writeObject(ObjectOutputStream oos) throws IOException {
    oos.defaultWriteObject();
    oos.writeInt(array.length);
    for (int i = 0; i < array.length; i++) {
        oos.writeObject(array[i]);
    }
}
 
Example 19
Project: HCFCore   File: AbstractReferenceMap.java   View Source Code Vote up 3 votes
/**
 * Replaces the superclass method to store 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 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
 * @throws IOException if an error occurs while writing to the stream
 */
@Override
protected void doWriteObject(final ObjectOutputStream out) throws IOException {
    out.writeInt(keyType.value);
    out.writeInt(valueType.value);
    out.writeBoolean(purgeValues);
    out.writeFloat(loadFactor);
    out.writeInt(data.length);
    for (final MapIterator<K, V> it = mapIterator(); it.hasNext();) {
        out.writeObject(it.next());
        out.writeObject(it.getValue());
    }
    out.writeObject(null);  // null terminate map
    // do not call super.doWriteObject() as code there doesn't work for reference map
}
 
Example 20
Project: monarch   File: RegionDataOrder.java   View Source Code Vote up 2 votes
/**
 * Serialize the RegionDataOrder based on <em>id</em>.
 *
 * @param out the object output stream
 * @throws IOException
 */
private void writeObject(ObjectOutputStream out) throws IOException {
  out.writeInt(this.id);
}