List of usage examples for java.io ObjectOutputStream writeObject
public final void writeObject(Object obj) throws IOException
From source file:de.iew.framework.utils.IewApplicationEvent.java
private void writeObject(ObjectOutputStream out) throws IOException { out.defaultWriteObject();// w w w.j a v a 2s.co m out.writeObject(source.toString()); }
From source file:de.tudarmstadt.ukp.experiments.argumentation.sequence.feature.deeplearning.EmbeddingsCachePreprocessor.java
@Override public void collectionProcessComplete() throws AnalysisEngineProcessException { try {/*from ww w .ja v a2 s.c om*/ Word2VecReader reader = new Word2VecReader(new File(EMBEDDINGS), true); String[] tokenArray = new ArrayList<>(tokens).toArray(new String[tokens.size()]); System.out.println("Vocabulary size: " + tokenArray.length); Embedding[] embeddings = reader.getEmbeddings(tokenArray); Map<String, Vector> cache = new HashMap<>(); if (tokenArray.length != embeddings.length) { throw new IllegalStateException(); } for (int i = 0; i < tokenArray.length; i++) { String token = tokenArray[i]; Embedding embedding = embeddings[i]; if (embedding != null) { cache.put(token, embedding.getVector()); } else { cache.put(token, null); } } File cacheFile = new File("TBD"); FileOutputStream fos = new FileOutputStream(cacheFile); ObjectOutputStream os = new ObjectOutputStream(fos); os.writeObject(cache); IOUtils.closeQuietly(fos); } catch (Exception e) { throw new AnalysisEngineProcessException(e); } }
From source file:net.vleu.par.android.rpc.SerializableCookie.java
private void writeObject(final ObjectOutputStream out) throws IOException { out.writeObject(this.cookie.getName()); out.writeObject(this.cookie.getValue()); out.writeObject(this.cookie.getComment()); out.writeObject(this.cookie.getDomain()); out.writeObject(this.cookie.getExpiryDate()); out.writeObject(this.cookie.getPath()); out.writeInt(this.cookie.getVersion()); out.writeBoolean(this.cookie.isSecure()); }
From source file:gumga.framework.application.GumgaTempFileService.java
public String create(GumgaFile gumgaFile) { String tempFileName = "uploadData" + (System.currentTimeMillis() * 1000 + new Random().nextInt(1000)); try { //TODO Arrumar o tratamento da Exception File folder = new File(gumgaValues.getUploadTempDir()); folder.mkdirs();/*from w ww . ja v a2 s. c o m*/ FileOutputStream fos = new FileOutputStream(gumgaValues.getUploadTempDir() + "/" + tempFileName); ObjectOutputStream oos = new ObjectOutputStream(fos); oos.writeObject(gumgaFile); oos.close(); fos.close(); return tempFileName; } catch (Exception ex) { log.error("erro ao criar arquivo temporario " + tempFileName, ex); } return "error"; }
From source file:com.topekalabs.bigmachine.lib.app.ContinuationSerializationTest.java
@Test public void simpleSerializationTest() throws Exception { MutableInt context = new MutableInt(); Continuation c = Continuation.startWith(new SimpleContinuationRunnable(), context); logger.debug("Is serializable: {}", c.isSerializable()); Assert.assertEquals("The value of the context was not set properly", SimpleContinuationRunnable.FIRST_VALUE, context.getValue());//from w w w .ja v a 2s . c o m ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(bos); oos.writeObject(c); oos.close(); ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(bos.toByteArray())); c = (Continuation) ois.readObject(); ois.close(); Continuation.continueWith(c, context); Assert.assertEquals("The value of the context was not set properly", SimpleContinuationRunnable.SECOND_VALUE, context.getValue()); }
From source file:foam.dao.index.PersistedIndex.java
@Override public Object wrap(Object state) { synchronized (file_) { try {/*from www. j a va2 s .c o m*/ long position = fos_.getChannel().position(); ObjectOutputStream oos = new ObjectOutputStream(bos_); oos.writeObject(state); oos.flush(); bos_.writeTo(fos_); bos_.flush(); bos_.reset(); return position; } catch (Throwable t) { throw new RuntimeException(t); } } }
From source file:com.earldouglas.xjdl.io.LicenseCreator.java
public String encryptLicense(License license, String key) throws Exception, NoSuchAlgorithmException, NoSuchPaddingException { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutputStream); objectOutputStream.writeObject(license); objectOutputStream.close();// w ww.java 2 s .c om byte[] serializedLicense = byteArrayOutputStream.toByteArray(); SecretKeySpec secretKeySpec = new SecretKeySpec(key.getBytes(), "AES"); Cipher cipher = Cipher.getInstance("AES"); cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec); byte[] encryptedLicense = cipher.doFinal(serializedLicense); String encodedLicense = Base64.encodeBase64String(encryptedLicense); encodedLicense = encodedLicense.replaceAll("\n", ""); encodedLicense = encodedLicense.replaceAll("\r", ""); return encodedLicense; }
From source file:com.brianjmelton.apcs.api.BasicCookieStoreSerializer.java
@Override public void persist(Map<URI, List<SerializableCookie>> cookies) throws PersistenceException { try {//from w ww .j av a 2s. c om OutputStream fout = new FileOutputStream(cookieFile); ObjectOutputStream oos = new ObjectOutputStream(fout); oos.writeObject(cookies); IOUtils.closeQuietly(oos); } catch (Throwable t) { throw new PersistenceException(t); } }
From source file:com.ab.http.SerializableCookie.java
/** * Write object.//from w w w . j a v a2s . c om * * @param out the out * @throws IOException Signals that an I/O exception has occurred. */ private void writeObject(ObjectOutputStream out) throws IOException { out.writeObject(cookie.getName()); out.writeObject(cookie.getValue()); out.writeObject(cookie.getComment()); out.writeObject(cookie.getDomain()); out.writeObject(cookie.getExpiryDate()); out.writeObject(cookie.getPath()); out.writeInt(cookie.getVersion()); out.writeBoolean(cookie.isSecure()); }
From source file:download.XBRLZipDownloader.java
/** * Saves the RSSFilingData in the same folder of the downloaded xbrl data * @param outputPath/*from w ww . j a v a 2 s .co m*/ * @param rssData */ private void saveRSSFilingData(String outputPath, RSSFilingData rssData) { try { FileOutputStream os = new FileOutputStream(new File(outputPath)); ObjectOutputStream objStream = new ObjectOutputStream(os); objStream.writeObject(rssData); } catch (FileNotFoundException ex) { ex.printStackTrace(); } catch (IOException ex) { ex.printStackTrace(); } }