List of usage examples for java.io ObjectOutputStream writeInt
public void writeInt(int val) throws IOException
From source file:com.axiomine.largecollections.util.LargeCollection.java
protected void serialize(java.io.ObjectOutputStream stream) throws IOException { System.out.println("Now serializing " + this.dbName); stream.writeObject(this.dbPath); stream.writeObject(this.dbName); stream.writeInt(this.cacheSize); stream.writeInt(this.size); stream.writeInt(this.bloomFilterSize); stream.writeObject(this.bloomFilter); this.db.close(); }
From source file:com.projity.interval.ValueObjectForIntervalTable.java
public void serializeCompact(ObjectOutputStream s) throws IOException { s.writeObject(name);/*from w w w. ja va 2 s . c o m*/ if (valueObjects == null) { s.writeInt(-1); return; } s.writeInt(valueObjects.size()); for (Iterator i = valueObjects.iterator(); i.hasNext();) { ValueObjectForInterval interval = (ValueObjectForInterval) i.next(); interval.serializeCompact(s, this); } }
From source file:org.codehaus.wadi.core.store.DiscStore.java
public void insert(Motable motable) throws Exception { File file = new File(sessionStoreDir, motable.getId() + streamer.getSuffixWithDot()); ObjectOutputStream oos = null; FileOutputStream fos = null;//w w w . ja va 2 s . co m try { fos = new FileOutputStream(file); oos = new ObjectOutputStream(fos); oos.writeLong(motable.getCreationTime()); oos.writeLong(motable.getLastAccessedTime()); oos.writeInt(motable.getMaxInactiveInterval()); oos.writeObject(motable.getId()); byte[] bodyAsByteArray = motable.getBodyAsByteArray(); oos.writeInt(bodyAsByteArray.length); oos.flush(); if (bodyAsByteArray.length > 0) { fos.write(bodyAsByteArray); } if (log.isTraceEnabled()) { log.trace("stored disc motable): " + file + ": " + bodyAsByteArray.length + " bytes"); } } catch (Exception e) { log.warn("store exclusive disc failed. File [" + file + "]", e); throw e; } finally { try { if (oos != null) { oos.close(); } } catch (IOException e) { log.warn("store exclusive disc) problem. File [" + file + "]", e); } } }
From source file:org.mrgeo.data.raster.RasterWritable.java
private synchronized void writeObject(ObjectOutputStream stream) throws IOException { stream.writeInt(getLength()); stream.write(getBytes(), 0, getLength()); }
From source file:org.aksw.dice.eaglet.uri.impl.FileBasedCachingUriCheckerManager.java
/** * Writes the cache to the {@link #tempCacheFile}. After that the * {@link #cacheFile} is deleted and the {@link #tempCacheFile} is renamed. * <b>NOTE</b> that this method should only be called if the * {@link #cacheWriteMutex} has been acquired. * /* w w w . ja v a2s. com*/ * @throws IOException */ private void performCacheStorage() throws IOException { eraseOldEntries(); FileOutputStream fout = null; ObjectOutputStream oout = null; try { fout = new FileOutputStream(tempCacheFile); oout = new ObjectOutputStream(fout); // first, serialize the number of URIs oout.writeInt(cache.assigned); // go over the mapping and serialize all existing pairs for (int i = 0; i < cache.allocated.length; ++i) { if (cache.allocated[i]) { oout.writeObject(((Object[]) cache.keys)[i]); oout.writeLong(cache.values[i]); } } } finally { IOUtils.closeQuietly(oout); IOUtils.closeQuietly(fout); } if (cacheFile.exists() && !cacheFile.delete()) { LOGGER.error("Cache file couldn't be deleted. Aborting."); return; } if (!tempCacheFile.renameTo(cacheFile)) { LOGGER.error("Temporary cache file couldn't be renamed. Aborting."); return; } cacheChanges = 0; }
From source file:org.largecollections.CacheSet.java
private void writeObject(java.io.ObjectOutputStream stream) throws IOException { stream.writeObject(this.folder); stream.writeObject(this.name); stream.writeInt(this.cacheSize); stream.writeInt(this.size); }
From source file:org.photovault.replication.ObjectHistory.java
/** Write all changes of the target object to output stream. First, the total number of changes is written as integer. Then the changes are written in topologically sorted order so that all predecessors of a change are written before it./*from ww w .j a v a2 s .com*/ @param os The output stream @throws java.io.IOException If an error occurs during writing. */ public void writeChanges(ObjectOutputStream os) throws IOException { Set<UUID> writtenIds = new HashSet<UUID>(); List<ChangeDTO<T>> changesToWrite = new ArrayList<ChangeDTO<T>>(allChanges.size()); for (Change<T> ch : heads) { prepareDtos(ch, writtenIds, changesToWrite); } os.writeInt(changesToWrite.size()); for (ChangeDTO<T> dto : changesToWrite) { os.writeObject(dto); } }
From source file:ddf.catalog.data.impl.MetacardTypeImpl.java
/** * Serializes this {@link MetacardTypeImpl} instance. * * @param stream the {@link ObjectOutputStream} that contains the object to be serialized * @throws IOException/*from w ww . j a v a 2 s. c om*/ * @serialData First, the name is written as a {@code String} by the default Java serialization * implementation, then the number of {@link AttributeDescriptor} objects is written as an ( * {@code int}), followed by all of the {@code AttributeDescriptor} objects in no guaranteed * sequence or order. */ private void writeObject(ObjectOutputStream stream) throws IOException { /* * defaultWriteObject() is invoked for greater flexibility and compatibility. See the * *Serialization Note* in MetacardImpl's class Javadoc. */ stream.defaultWriteObject(); stream.writeInt(descriptors.size()); for (AttributeDescriptor descriptor : descriptors.values()) { stream.writeObject(descriptor); } }
From source file:com.izforge.izpack.compiler.packager.impl.MultiVolumePackager.java
/** * Writes the pack files./* ww w. j a va2s. c o m*/ * <p/> * The file data is written to <tt>volumes</tt>, whilst the meta-data is written to <tt>packStream</tt>. * * @param packInfo the pack information * @param volumes the volumes to write to * @param pack the pack * @param packStream the stream to write the pack meta-data to * @param targetDir the target directory for loose files * @throws IOException for any I/O error */ private void writePackFiles(PackInfo packInfo, FileSpanningOutputStream volumes, Pack pack, ObjectOutputStream packStream, File targetDir) throws IOException { // write the file meta-data Set<PackFile> files = packInfo.getPackFiles(); packStream.writeInt(files.size()); for (PackFile packfile : files) { XPackFile pf = new XPackFile(packfile); File file = packInfo.getFile(packfile); logger.fine("Next file: " + file.getAbsolutePath()); if (!pf.isDirectory()) { if (!pack.isLoose()) { writePackFile(file, volumes, pf); } else { // just copy the file to the target directory FileUtils.copyFile(file, new File(targetDir, pf.getRelativeSourcePath())); } } // write pack file meta-data packStream.writeObject(pf); packStream.flush(); // make sure it is written // even if not written, it counts towards pack size pack.addFileSize(pf.length()); } if (pack.getFileSize() > pack.getSize()) { pack.setSize(pack.getFileSize()); } }
From source file:ti.modules.titanium.network.TiCookieStore.java
private String encodeCookie(Cookie cookie) { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); try {// w w w. j a va 2 s . c o m ObjectOutputStream objectOutputStream = new ObjectOutputStream(outputStream); objectOutputStream.writeObject(cookie.getName()); objectOutputStream.writeObject(cookie.getValue()); objectOutputStream.writeObject(cookie.getComment()); objectOutputStream.writeObject(cookie.getDomain()); objectOutputStream.writeInt(cookie.getVersion()); objectOutputStream.writeBoolean(cookie.isSecure()); objectOutputStream.writeObject(cookie.getExpiryDate()); objectOutputStream.writeObject(cookie.getPath()); } catch (Exception e) { Log.w(TAG, "Failed to encode cookie", Log.DEBUG_MODE); return null; } return new String(Hex.encodeHex(outputStream.toByteArray())); }