List of usage examples for java.io ObjectOutputStream writeInt
public void writeInt(int val) throws IOException
From source file:it.unimi.di.big.mg4j.document.TRECDocumentCollection.java
private void writeObject(final ObjectOutputStream s) throws IOException { s.defaultWriteObject();/*from w w w . j a v a 2s . c om*/ s.writeLong(descriptors.size64()); for (TRECDocumentDescriptor descriptor : descriptors) { s.writeInt(descriptor.fileIndex); s.writeLong(descriptor.startMarker); s.writeInt(descriptor.intermediateMarkerDiff); s.writeInt(descriptor.stopMarkerDiff); } }
From source file:org.protempa.proposition.AbstractProposition.java
protected void writeAbstractProposition(ObjectOutputStream s) throws IOException { s.writeObject(this.id); s.writeObject(this.uniqueId); if (this.properties == null) { s.writeInt(0); } else {/* w w w . j a v a 2 s.c o m*/ s.writeInt(this.properties.size()); for (Map.Entry<String, Value> me : this.properties.entrySet()) { String propertyName = me.getKey(); Value val = me.getValue(); s.writeObject(propertyName); s.writeObject(val); } } if (this.references == null) { s.writeInt(0); } else { s.writeInt(this.references.size()); for (Map.Entry<String, List<UniqueId>> me : this.references.entrySet()) { s.writeObject(me.getKey()); List<UniqueId> val = me.getValue(); if (val == null) { s.writeInt(0); } else { s.writeInt(val.size()); for (UniqueId uid : val) { s.writeObject(uid); } } } } s.writeObject(this.sourceSystem); s.writeObject(this.changes); }
From source file:edu.stanford.muse.datacache.BlobStore.java
private synchronized void pack_to_stream(ObjectOutputStream oos) throws IOException { oos.writeObject(uniqueBlobs);/*from w w w. j a va2s . c om*/ oos.writeObject(id_map); oos.writeObject(views); oos.writeInt(next_data_id); oos.flush(); }
From source file:it.scoppelletti.programmerpower.web.control.ActionBase.java
/** * Serializza l’oggetto./*www. j a va 2 s . c om*/ * * @param out Flusso di scrittura. * @serialData Formato di default seguito dai messaggi: * * <P><OL> * <LI>Numero dei messaggi. * <LI>Sequenza dei messaggi. * </OL></P> */ private void writeObject(ObjectOutputStream out) throws IOException { out.defaultWriteObject(); out.writeInt(myMessages.size()); for (ActionMessage msg : myMessages) { out.writeObject(msg); } }
From source file:com.mgmtp.jfunk.core.ui.JFunkFrame.java
private void writeState() { ObjectOutputStream oos = null; try {/*from w ww.j a v a 2s. c om*/ oos = new ObjectOutputStream(new FileOutputStream("jFunkFrame.state")); oos.writeObject(getBounds()); oos.writeInt(getExtendedState()); oos.writeObject(tree.getSelectionPaths()); oos.writeInt(jFunkPropertyFilesComboBox.getSelectedIndex()); oos.writeInt(testSystemsComboBox.getSelectedIndex()); oos.writeInt(mailConfigurationsComboBox.getSelectedIndex()); oos.writeInt(threadCountComboBox.getSelectedIndex()); oos.writeInt(parallelComboBox.getSelectedIndex()); } catch (final IOException ex) { log.error("Error writing prferences.", ex); } finally { IOUtils.closeQuietly(oos); } }
From source file:be.fgov.kszbcss.rhq.websphere.config.cache.ConfigQueryCache.java
void persist() { if (log.isDebugEnabled()) { log.debug("Persisting cache to " + persistentFile); }//w ww . j av a2s . com try { ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(persistentFile)); try { ConfigQueryCacheEntry<?>[] entries; synchronized (cache) { entries = cache.values().toArray(new ConfigQueryCacheEntry<?>[cache.size()]); } out.writeInt(entries.length); for (ConfigQueryCacheEntry<?> entry : entries) { synchronized (entry) { out.writeObject(entry); } } } finally { out.close(); } } catch (IOException ex) { log.error("Failed to persist cache", ex); } }
From source file:IntObjectHashMap.java
/** * Save the state of the <tt>IntObjectHashMap</tt> instance to a stream (i.e., * serialize it)./*from ww w .j av a2 s .c om*/ * * @serialData The <i>capacity</i> of the IntObjectHashMap (the length of the * bucket array) is emitted (int), followed by the * <i>size</i> of the IntObjectHashMap (the number of key-value * mappings), followed by the key (Object) and value (Object) * for each key-value mapping represented by the IntObjectHashMap * The key-value mappings are emitted in the order that they * are returned by <tt>entrySet().iterator()</tt>. */ private void writeObject(java.io.ObjectOutputStream s) throws IOException { // Write out the threshold, loadfactor, and any hidden stuff s.defaultWriteObject(); // Write out number of buckets s.writeInt(table.length); // Write out size (number of Mappings) s.writeInt(size); // Write out keys and values (alternating) int c = 0; for (int i = 0; c < size && i < table.length; i++) { Entry e = table[i]; for (; e != null; e = e.next, ++c) { s.writeInt(e.key); s.writeObject(e.getValue()); } } }
From source file:com.izforge.izpack.compiler.packager.impl.Packager.java
/** * Write Packs to primary jar or each to a separate jar. *//*from w ww . j a va 2 s . c o m*/ protected void writePacks() throws Exception { final int num = packsList.size(); sendMsg("Writing " + num + " Pack" + (num > 1 ? "s" : "") + " into installer"); // Map to remember pack number and bytes offsets of back references Map<File, Object[]> storedFiles = new HashMap<File, Object[]>(); // Pack200 files map Map<Integer, File> pack200Map = new HashMap<Integer, File>(); int pack200Counter = 0; // Force UTF-8 encoding in order to have proper ZipEntry names. primaryJarStream.setEncoding("utf-8"); // First write the serialized files and file metadata data for each pack // while counting bytes. int packNumber = 0; IXMLElement root = new XMLElementImpl("packs"); for (PackInfo packInfo : packsList) { Pack pack = packInfo.getPack(); pack.nbytes = 0; if ((pack.id == null) || (pack.id.length() == 0)) { pack.id = pack.name; } // create a pack specific jar if required // REFACTOR : Repare web installer // REFACTOR : Use a mergeManager for each packages that will be added to the main merger // if (packJarsSeparate) { // See installer.Unpacker#getPackAsStream for the counterpart // String name = baseFile.getName() + ".pack-" + pack.id + ".jar"; // packStream = IoHelper.getJarOutputStream(name, baseFile.getParentFile()); // } sendMsg("Writing Pack " + packNumber + ": " + pack.name, PackagerListener.MSG_VERBOSE); // Retrieve the correct output stream org.apache.tools.zip.ZipEntry entry = new org.apache.tools.zip.ZipEntry( RESOURCES_PATH + "packs/pack-" + pack.id); primaryJarStream.putNextEntry(entry); primaryJarStream.flush(); // flush before we start counting ByteCountingOutputStream dos = new ByteCountingOutputStream(outputStream); ObjectOutputStream objOut = new ObjectOutputStream(dos); // We write the actual pack files objOut.writeInt(packInfo.getPackFiles().size()); for (PackFile packFile : packInfo.getPackFiles()) { boolean addFile = !pack.loose; boolean pack200 = false; File file = packInfo.getFile(packFile); if (file.getName().toLowerCase().endsWith(".jar") && info.isPack200Compression() && isNotSignedJar(file)) { packFile.setPack200Jar(true); pack200 = true; } // use a back reference if file was in previous pack, and in // same jar Object[] info = storedFiles.get(file); if (info != null && !packJarsSeparate) { packFile.setPreviousPackFileRef((String) info[0], (Long) info[1]); addFile = false; } objOut.writeObject(packFile); // base info if (addFile && !packFile.isDirectory()) { long pos = dos.getByteCount(); // get the position if (pack200) { /* * Warning! * * Pack200 archives must be stored in separated streams, as the Pack200 unpacker * reads the entire stream... * * See http://java.sun.com/javase/6/docs/api/java/util/jar/Pack200.Unpacker.html */ pack200Map.put(pack200Counter, file); objOut.writeInt(pack200Counter); pack200Counter = pack200Counter + 1; } else { FileInputStream inStream = new FileInputStream(file); long bytesWritten = IoHelper.copyStream(inStream, objOut); inStream.close(); if (bytesWritten != packFile.length()) { throw new IOException("File size mismatch when reading " + file); } } storedFiles.put(file, new Object[] { pack.id, pos }); } // even if not written, it counts towards pack size pack.nbytes += packFile.size(); } // Write out information about parsable files objOut.writeInt(packInfo.getParsables().size()); for (ParsableFile parsableFile : packInfo.getParsables()) { objOut.writeObject(parsableFile); } // Write out information about executable files objOut.writeInt(packInfo.getExecutables().size()); for (ExecutableFile executableFile : packInfo.getExecutables()) { objOut.writeObject(executableFile); } // Write out information about updatecheck files objOut.writeInt(packInfo.getUpdateChecks().size()); for (UpdateCheck updateCheck : packInfo.getUpdateChecks()) { objOut.writeObject(updateCheck); } // Cleanup objOut.flush(); if (!compressor.useStandardCompression()) { outputStream.close(); } primaryJarStream.closeEntry(); // close pack specific jar if required if (packJarsSeparate) { primaryJarStream.closeAlways(); } IXMLElement child = new XMLElementImpl("pack", root); child.setAttribute("nbytes", Long.toString(pack.nbytes)); child.setAttribute("name", pack.name); if (pack.id != null) { child.setAttribute("id", pack.id); } root.addChild(child); packNumber++; } // Now that we know sizes, write pack metadata to primary jar. primaryJarStream.putNextEntry(new org.apache.tools.zip.ZipEntry(RESOURCES_PATH + "packs.info")); ObjectOutputStream out = new ObjectOutputStream(primaryJarStream); out.writeInt(packsList.size()); for (PackInfo packInfo : packsList) { out.writeObject(packInfo.getPack()); } out.flush(); primaryJarStream.closeEntry(); // Pack200 files Pack200.Packer packer = createAgressivePack200Packer(); for (Integer key : pack200Map.keySet()) { File file = pack200Map.get(key); primaryJarStream .putNextEntry(new org.apache.tools.zip.ZipEntry(RESOURCES_PATH + "packs/pack200-" + key)); JarFile jar = new JarFile(file); packer.pack(jar, primaryJarStream); jar.close(); primaryJarStream.closeEntry(); } }
From source file:net.sf.nmedit.jtheme.store.DefaultStorageContext.java
private void __writeCache(File cacheFile) throws Exception { ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream(cacheFile))); try {//from w ww . j a va 2 s. c o m // css out.writeObject(cssStyleSheet); // defs out.writeInt(imageResourceMap.size()); for (Object key : imageResourceMap.keySet()) { out.writeObject(key); Object ir = imageResourceMap.get(key); out.writeObject(ir); } // modules out.writeInt(moduleStoreMap.size()); for (ModuleElement e : moduleStoreMap.values()) { out.writeObject(e); } } finally { out.flush(); out.close(); } }
From source file:tvbrowser.core.Settings.java
/** * Stores the window settings for this plugin */// w w w . jav a2 s . c om private static void storeWindowSettings() { File windowSettingsFile = new File(Settings.getUserSettingsDirName(), WINDOW_SETTINGS_FILE); StreamUtilities.objectOutputStreamIgnoringExceptions(windowSettingsFile, new ObjectOutputStreamProcessor() { public void process(ObjectOutputStream out) throws IOException { out.writeInt(1); // write version out.writeInt(mWindowSettings.size()); for (String key : mWindowSettings.keySet()) { WindowSetting setting = mWindowSettings.get(key); if (setting != null) { out.writeUTF(key); mWindowSettings.get(key).saveSettings(out); } } out.close(); } }); }