List of usage examples for java.io ObjectOutputStream writeUTF
public void writeUTF(String str) throws IOException
From source file:com.mgmtp.jfunk.common.util.Configuration.java
/** * @serialData The name of the zip file. *///w w w . ja v a 2 s. c om private void writeObject(final ObjectOutputStream oos) throws IOException { oos.defaultWriteObject(); oos.writeUTF(zipArchive.getName()); }
From source file:com.flowpowered.api.geo.discrete.Point.java
private void writeObject(java.io.ObjectOutputStream out) throws IOException { out.defaultWriteObject();/*from ww w . j a v a 2s .c om*/ out.writeUTF(world != null ? world.getName() : "null"); }
From source file:com.qwazr.utils.server.InFileSessionPersistenceManager.java
private void writeSessionAttribute(ObjectOutputStream out, String attribute, Object object) { if (attribute == null || object == null) return;// w ww . j a v a 2 s. c om if (!(object instanceof Serializable)) return; try { out.writeUTF(attribute); // Attribute name stored as string } catch (IOException e) { if (logger.isErrorEnabled()) logger.error("Cannot write session attribute " + attribute + ": persistence aborted."); return; // The attribute cannot be written, we abort } try { out.writeObject(object); return; // The object was written, job done, we can exit } catch (IOException e) { if (logger.isWarnEnabled()) logger.warn("Cannot write session object " + object); try { out.writeObject(SerializationUtils.NullEmptyObject.INSTANCE); } catch (IOException e1) { if (logger.isErrorEnabled()) logger.error("Cannot write NULL session object for attribute " + attribute + ": persistence aborted."); } } }
From source file:com.hipu.bdb.util.UURI.java
private void writeObject(ObjectOutputStream stream) throws IOException { stream.writeUTF(toCustomString()); }
From source file:com.izforge.izpack.compiler.packager.impl.MultiVolumePackager.java
/** * Writes packs to one or more <em>.pak</em> volumes. * <p/>/*from w w w .ja v a2 s . c o m*/ * Pack meta-data is written to the installer jar. * * @throws IOException for any I/O error */ @Override protected void writePacks() throws IOException { String classname = getClass().getSimpleName(); // propagate the configuration to the variables, for debugging purposes getVariables().setProperty(classname + "." + FIRST_VOLUME_FREE_SPACE, Long.toString(maxFirstVolumeSize)); getVariables().setProperty(classname + "." + VOLUME_SIZE, Long.toString(maxVolumeSize)); List<PackInfo> packs = getPacksList(); final int count = packs.size(); sendMsg("Writing " + count + " Pack" + (count > 1 ? "s" : "") + " into installer"); logger.fine("Writing " + count + " Pack" + (count > 1 ? "s" : "") + " into installer"); logger.fine("First volume size: " + maxFirstVolumeSize); logger.fine("Subsequent volume size: " + maxVolumeSize); File volume = new File(getInfo().getInstallerBase() + ".pak").getAbsoluteFile(); int volumes = writePacks(packs, volume); // write metadata for reading in volumes logger.fine("Written " + volumes + " volumes"); JarOutputStream installerJar = getInstallerJar(); installerJar.putNextEntry(new ZipEntry(RESOURCES_PATH + "volumes.info")); ObjectOutputStream out = new ObjectOutputStream(installerJar); out.writeInt(volumes); out.writeUTF(volume.getName()); out.flush(); installerJar.closeEntry(); // Now that we know sizes, write pack metadata to primary jar. installerJar.putNextEntry(new ZipEntry(RESOURCES_PATH + "packs.info")); out = new ObjectOutputStream(installerJar); out.writeInt(count); for (PackInfo pack : packs) { out.writeObject(pack.getPack()); } out.flush(); installerJar.closeEntry(); }
From source file:com.inmobi.grill.driver.hive.TestRemoteHiveDriver.java
private byte[] persistContext(QueryContext ctx) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(baos); try {//from w w w. j a v a 2s . c o m out.writeObject(ctx); boolean isDriverAvailable = (ctx.getSelectedDriver() != null); out.writeBoolean(isDriverAvailable); if (isDriverAvailable) { out.writeUTF(ctx.getSelectedDriver().getClass().getName()); } } finally { out.flush(); out.close(); baos.close(); } return baos.toByteArray(); }
From source file:com.qwazr.server.InFileSessionPersistenceManager.java
private void writeSessionAttribute(final ObjectOutputStream draftOut, final ObjectOutputStream sessionOut, final String attribute, final Object object) { if (attribute == null || object == null || !(object instanceof Serializable)) return;/* w w w . j a va 2 s.c o m*/ // First we try to write it to the draftOutputStream try { draftOut.writeObject(object); } catch (IOException e) { LOGGER.warning(() -> "Cannot write attribute session object (draft test) " + attribute + " - " + object.getClass() + " - " + e.getMessage()); return; } try { sessionOut.writeUTF(attribute); // Attribute name stored as string sessionOut.writeObject(object); } catch (IOException e) { // The attribute cannot be written, we abort throw new CancellationException("Cannot write session attribute " + attribute + ": persistence aborted - " + object.getClass() + " - " + e.getMessage()); } }
From source file:com.cyberway.issue.crawler.datamodel.CandidateURI.java
/** * Custom serialization writing 'uuri' and 'via' as Strings, rather * than the bloated full serialization of their object classes, and * an empty alist as 'null'. Shrinks serialized form by 50% or more * in short tests. /* w w w . j ava2s . c o m*/ * * @param stream * @throws IOException */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); stream.writeUTF(uuri.toString()); stream.writeObject((via == null) ? null : via.getURI()); stream.writeObject((alist == null) ? null : alist); }
From source file:bin.spider.frame.uri.CandidateURI.java
/** * Custom serialization writing 'uuri' and 'via' as Strings, rather * than the bloated full serialization of their object classes, and * an empty alist as 'null'. Shrinks serialized form by 50% or more * in short tests. /*from w ww . j a va 2s.c o m*/ * * @param stream * @throws IOException * @throws URIException */ private void writeObject(ObjectOutputStream stream) throws IOException, URIException { stream.defaultWriteObject(); stream.writeUTF(uuri.toString()); stream.writeObject((via == null) ? null : via.getURI()); stream.writeObject((alist == null) ? null : alist); }
From source file:idontwant2see.IDontWant2See.java
public void writeData(final ObjectOutputStream out) throws IOException { // sort the list so that often used entries are in the front (for faster lookup) Collections.sort(mSettings.getSearchList(), new Comparator<IDontWant2SeeListEntry>() { public int compare(IDontWant2SeeListEntry o1, IDontWant2SeeListEntry o2) { return o2.getLastMatchedDate().compareTo(o1.getLastMatchedDate()); }/* w w w .j av a 2 s . c o m*/ }); out.writeInt(7); //version out.writeInt(mSettings.getSearchList().size()); for (IDontWant2SeeListEntry entry : mSettings.getSearchList()) { entry.writeData(out); } out.writeBoolean(mSettings.isSimpleMenu()); out.writeBoolean(mSettings.isSwitchToMyFilter()); out.writeUTF(mSettings.getLastEnteredExclusionString()); mSettings.getLastUsedDate().writeData((DataOutput) out); out.writeByte(mSettings.getProgramImportance()); }