FileOutputStream fos = context.openFileOutput(fileName, Context.MODE_PRIVATE); ObjectOutputStream os = new ObjectOutputStream(fos); os.writeObject(this); os.close(); fos.close();
private void save() throws IOException { ObjectOutputStream stream = null; try { stream = new ObjectOutputStream(new FileOutputStream(fHistoryStore)); stream.writeObject(this); } finally { if (stream != null) { stream.close(); } } }
@SneakyThrows private InputStream getInputStream(final Object value) { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutputStream); objectOutputStream.writeObject(value); objectOutputStream.flush(); objectOutputStream.close(); return new ByteArrayInputStream(byteArrayOutputStream.toByteArray()); }
public static byte[] serializeKerberosTicket(KerberosTicket tgt) throws Exception { ByteArrayOutputStream bao = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(bao); out.writeObject(tgt); out.flush(); out.close(); return bao.toByteArray(); }
private void save() throws IOException { ObjectOutputStream stream = new ObjectOutputStream(new FileOutputStream( fHistoryStore)); stream.writeObject(this); stream.close(); }
public static byte[] javaSerialize(Object obj) { try { ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(bos); oos.writeObject(obj); oos.close(); return bos.toByteArray(); } catch (IOException e) { throw new RuntimeException(e); } }
public static <T> void serializeCounter(Counter<T> c, String filename) throws IOException { // serialize to file ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream(filename))); out.writeObject(c); out.close(); }
@SneakyThrows protected InputStream getInputStream(final Object value) { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutputStream); objectOutputStream.writeObject(value); objectOutputStream.flush(); objectOutputStream.close(); return new ByteArrayInputStream(byteArrayOutputStream.toByteArray()); }
public static void outputModel(String fileName, Classifier<String, String> clf) { FileOutputStream fo = null; try { fo = new FileOutputStream(fileName); ObjectOutputStream so = new ObjectOutputStream(fo); so.writeObject(clf); so.flush(); so.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
@Override public byte[] serialize(Object object) { try { ByteArrayOutputStream bos = new ByteArrayOutputStream(); GZIPOutputStream gos = new GZIPOutputStream(bos); ObjectOutputStream oos = new ObjectOutputStream(gos); oos.writeObject(object); oos.close(); return bos.toByteArray(); } catch (IOException e) { throw new RuntimeException(e); } }
File file = new File(getDir("data", MODE_PRIVATE), "map"); ObjectOutputStream outputStream = new ObjectOutputStream(new FileOutputStream(file)); outputStream.writeObject(map); outputStream.flush(); outputStream.close();
@Override public byte[] serialize(Object object) { try { ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(bos); oos.writeObject(object); oos.close(); return bos.toByteArray(); } catch (IOException e) { throw new RuntimeException(e); } }
public void save(String path) throws IOException { // save the CRF this.classifier.serializeClassifier(path); // save the additional arguments FileOutputStream fos = new FileOutputStream(path + ".extra"); ObjectOutputStream out = new ObjectOutputStream(fos); out.writeObject(this.gazetteerLocation); out.writeObject(this.annotationsToSkip); out.writeObject(this.useSubTypes); out.writeObject(this.useBIO); out.close(); }
private static String calcClassSign(String name) { try { Class<?> clazz = Class.forName(name); ByteArrayOutputStream result = new ByteArrayOutputStream(); ObjectOutputStream outputStream = new ObjectOutputStream(result); outputStream.writeObject(clazz); outputStream.close(); MessageDigest crypt = MessageDigest.getInstance("SHA-1"); crypt.reset(); crypt.update(result.toByteArray()); return new BigInteger(1, crypt.digest()).toString(16); } catch (Exception e) { throw new IllegalStateException("Can't calculate sign of " + name, e); } }
FileOutputStream fos = new FileOutputStream("t.tmp"); ObjectOutputStream oos = new ObjectOutputStream(fos); oos.writeObject(clubs); oos.close();
@Override public Buffer apply(T t) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(t); oos.flush(); oos.close(); } catch (IOException e) { throw new IllegalStateException(e.getMessage(), e); } return Buffer.wrap(baos.toByteArray()); }
/** * Saves a list of MRU files out to a file. */ public void save() { File file = new File(getFilename()); try { ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(file)); oos.writeObject(_mruFileList); oos.flush(); oos.close(); } catch (Exception e) { // do nothing e.printStackTrace(); } }
private static String calcClassSign(String name) { try { Class<?> clazz = Class.forName(name); ByteArrayOutputStream result = new ByteArrayOutputStream(); ObjectOutputStream outputStream = new ObjectOutputStream(result); outputStream.writeObject(clazz); outputStream.close(); MessageDigest crypt = MessageDigest.getInstance("SHA-1"); crypt.reset(); crypt.update(result.toByteArray()); return new BigInteger(1, crypt.digest()).toString(16); } catch (Exception e) { throw new IllegalStateException("Can't calculate sign of " + name, e); } }
public static void serialize(Object obj, String filePath) throws Exception { FileOutputStream fos = new FileOutputStream(filePath); ObjectOutputStream oos = new ObjectOutputStream(fos); oos.writeObject(obj); oos.flush(); oos.close(); fos.close(); }
private static String calcClassSign(String name) { try { Class<?> clazz = Class.forName(name); ByteArrayOutputStream result = new ByteArrayOutputStream(); ObjectOutputStream outputStream = new ObjectOutputStream(result); outputStream.writeObject(clazz); outputStream.close(); MessageDigest crypt = MessageDigest.getInstance("SHA-1"); crypt.reset(); crypt.update(result.toByteArray()); return new BigInteger(1, crypt.digest()).toString(16); } catch (Exception e) { throw new IllegalStateException("Can't calculate sign of " + name, e); } }