Java ObjectOutputStream Write saveObject2FileImpl(final Serializable object, final File file)

Here you can find the source of saveObject2FileImpl(final Serializable object, final File file)

Description

save Object File Impl

License

Apache License

Declaration

private static void saveObject2FileImpl(final Serializable object, final File file) throws IOException 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.*;

import java.util.zip.DeflaterOutputStream;

public class Main {
    private static void saveObject2FileImpl(final Serializable object, final File file) throws IOException {
        ObjectOutputStream output = null;

        try {//from  w  w  w  .ja v  a  2s.  c o m
            output = new ObjectOutputStream(
                    new BufferedOutputStream(new DeflaterOutputStream(new FileOutputStream(file)), 1024 * 1024));

            output.writeObject(object);

            output.flush();
            output.close();
            output = null;
        } finally {
            if (output != null) {
                output.close();
            }
        }
    }
}

Related

  1. saveObject(String filename, Object obj)
  2. saveObject(String filename, Object obj)
  3. saveObject(String filePath, Serializable obj)
  4. saveObject(T object, File file, boolean use_compression)
  5. saveObject2File(final Serializable object, final File file)
  6. saveObjectInFile(String fileName, Object obj)
  7. saveObjectToFile(File file, Object object)
  8. saveObjectToFile(File thatFile, Object... thisObject)
  9. saveObjectToFile(final Object object, final String fileName)