Java Object Save writeObjectToFile(Object oObject, File destDir, String filename)

Here you can find the source of writeObjectToFile(Object oObject, File destDir, String filename)

Description

write Object To File

License

Open Source License

Declaration

public static void writeObjectToFile(Object oObject, File destDir, String filename) throws IOException 

Method Source Code

//package com.java2s;
//it under the terms of the GNU Affero General Public License as published by

import java.io.BufferedOutputStream;

import java.io.File;

import java.io.FileOutputStream;
import java.io.IOException;

import java.io.OutputStream;

public class Main {
    public static void writeObjectToFile(Object oObject, File destDir, String filename) throws IOException {
        File dest = new File(destDir, filename);
        if (dest.exists())
            dest.delete();/* ww w  . j a  v  a2  s.  c  om*/

        OutputStream outStream = null;
        try {
            outStream = new BufferedOutputStream(new FileOutputStream(dest));
            outStream.write((byte[]) oObject);
        } finally {
            if (outStream != null) {
                outStream.close();
            }
        }
    }
}

Related

  1. writeObjectToFile(Object o, String fileName)
  2. writeObjectToFile(Object obj, File f)
  3. writeObjectToFile(Object obj, String fileName)
  4. writeObjectToFile(Object obj, String path)
  5. writeObjectToFile(Object object, File file)
  6. writeObjectToFile(String dirname, String filename, Object obj)
  7. writeObjectToFile(String fileName, Object obj)
  8. writeObjectToFile(String filename, Serializable s)
  9. writeObjectToFile(String filename, T object)