Android Object Serialization writeObjectToFile(File fileLocation, Object obj)

Here you can find the source of writeObjectToFile(File fileLocation, Object obj)

Description

write Object To File

Declaration

public static void writeObjectToFile(File fileLocation, Object obj)
            throws IOException 

Method Source Code

//package com.java2s;

import java.io.File;

import java.io.FileOutputStream;

import java.io.IOException;

import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import java.io.OutputStream;

import java.util.zip.GZIPOutputStream;

public class Main {
    public static void writeObjectToFile(File fileLocation, Object obj)
            throws IOException {
        OutputStream file = new FileOutputStream(fileLocation);
        OutputStream buffer = new GZIPOutputStream(file);
        try (ObjectOutput output = new ObjectOutputStream(buffer)) {
            output.writeObject(obj);// w w w . ja v  a  2s. c  o  m
        }
    }
}

Related

  1. loadObjectFromFile(String filename)
  2. readObjectFromFile(File fileLocation)
  3. readObjectFromFile(String filename)
  4. saveObjectAsFile(String filename, Object object)
  5. writeObjectToFile(Serializable obj, String filename)
  6. objectToString(Object o)
  7. stringToObject(String s)
  8. getBytes(Serializable obj)