List of usage examples for java.io ObjectOutputStream writeObject
public final void writeObject(Object obj) throws IOException
From source file:com.timesoft.kaitoo.ws.hibernate.AbstractPojo.java
/** * DOCUMENT ME!/*from w ww.j av a 2s. co m*/ * * @return DOCUMENT ME! * * @throws Exception DOCUMENT ME! */ public byte[] serialize() throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); try { oos.writeObject(this); } finally { oos.close(); } return baos.toByteArray(); }
From source file:edu.uci.ics.jung.visualization.layout.PersistentLayoutImpl.java
/** * save the Vertex locations to a file//from w w w . j a v a 2 s.co m * @param fileName the file to save to * @throws an IOException if the file cannot be used */ public void persist(String fileName) throws IOException { for (V v : getGraph().getVertices()) { Point p = new Point(transform(v)); map.put(v, p); } ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(fileName)); oos.writeObject(map); oos.close(); }
From source file:org.taverna.server.master.localworker.RunDatabase.java
private void logLength(String message, Object obj) { if (!log.isDebugEnabled()) return;// w ww . j ava2s . com try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(obj); oos.close(); log.debug(message + ": " + baos.size()); } catch (Exception e) { log.warn("oops", e); } }
From source file:com.smartitengineering.cms.content.api.impl.IdTest.java
public void testWorkspaceIdSerialization() throws IOException, ClassNotFoundException { ByteArrayOutputStream baoStream = new ByteArrayOutputStream(); ObjectOutputStream outputStream = new ObjectOutputStream(baoStream); outputStream.writeObject(workspaceId); IOUtils.closeQuietly(outputStream);/* ww w . j av a 2 s . c o m*/ ByteArrayInputStream baiStream = new ByteArrayInputStream(baoStream.toByteArray()); ObjectInputStream inputStream = new ObjectInputStream(baiStream); System.out.println(baoStream.toString()); assertEquals(workspaceId, inputStream.readObject()); baoStream = new ByteArrayOutputStream(); DataOutputStream dataOutputStream = new DataOutputStream(baoStream); workspaceId.writeExternal(dataOutputStream); IOUtils.closeQuietly(dataOutputStream); System.out.println(workspaceId.toString() + " ================= " + baoStream.toString()); assertEquals(workspaceId.toString(), baoStream.toString()); WorkspaceIdImpl idImpl = new WorkspaceIdImpl(); idImpl.readExternal(new DataInputStream(new ByteArrayInputStream(baoStream.toByteArray()))); assertEquals(workspaceId, idImpl); }
From source file:com.sliit.rules.RuleContainer.java
private void loadSaveModel(String filePath, boolean status) { System.out.println("rule loadSaveModel"); if (status) { try {/*from w ww. java2 s.c o m*/ ObjectOutputStream outStream = new ObjectOutputStream(new FileOutputStream(filePath)); outStream.writeObject(ruleMoldel); outStream.flush(); outStream.close(); } catch (IOException e) { log.error("Error occurred:" + e.getMessage()); } } else { try { ObjectInputStream inputStream = new ObjectInputStream(new FileInputStream(filePath)); ruleMoldel = (JRip) inputStream.readObject(); } catch (IOException e) { log.error("Error occurred:" + e.getMessage()); } catch (ClassNotFoundException e) { log.error("Error occurred:" + e.getMessage()); } } }
From source file:com.bskyb.cg.environments.hash.PersistentHash.java
private synchronized void appendEntryToStore(Message message) throws IOException { String filename = message.getKey(); File file = new File(dirname, filename); FileOutputStream fos = new FileOutputStream(file, true); BufferedOutputStream bos = new BufferedOutputStream(fos); ObjectOutputStream oos = new ObjectOutputStream(bos); oos.writeObject(message); oos.flush();// www.ja v a2s .com oos.close(); fos.flush(); fos.close(); }
From source file:de.tudarmstadt.ukp.dkpro.core.io.bincas.BinaryCasWriter.java
private void writeTypeSystem(JCas aJCas, OutputStream aOS) throws IOException { ObjectOutputStream typeOS = new ObjectOutputStream(aOS); CASMgrSerializer casMgrSerializer = serializeCASMgr(aJCas.getCasImpl()); typeOS.writeObject(casMgrSerializer); typeOS.flush();/*from w w w . j a va2s.c om*/ }
From source file:com.joliciel.talismane.parser.ParsingConstrainerImpl.java
@Override public void onCompleteParse() { if (this.transitionSystem == null) this.transitionSystem = TalismaneSession.getTransitionSystem(); if (this.file != null) { try {// w w w .j a va2 s. c om ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(file, false)); zos.putNextEntry(new ZipEntry("ParsingConstrainer.obj")); ObjectOutputStream oos = new ObjectOutputStream(zos); try { oos.writeObject(this); } finally { oos.flush(); } zos.flush(); zos.close(); } catch (IOException ioe) { LogUtils.logError(LOG, ioe); throw new RuntimeException(ioe); } } }
From source file:com.servoy.extensions.plugins.http.AllowedCertTrustStrategy.java
public void add(X509Certificate[] certificates) { getCertificatesHolder();//from ww w. j a v a2 s . c o m holder.add(certificates); File file = new File(System.getProperty("user.home"), J2DBGlobals.CLIENT_LOCAL_DIR + "servoy.ks"); //$NON-NLS-1$//$NON-NLS-2$ if (!file.getParentFile().exists()) file.getParentFile().mkdirs(); ObjectOutputStream oos = null; try { oos = new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream(file))); oos.writeObject(holder); } catch (Exception e) { Debug.error(e); } finally { try { if (oos != null) oos.close(); } catch (Exception e) { } } }