Java ObjectOutputStream Write saveSerializableObject(Object obj, String path)

Here you can find the source of saveSerializableObject(Object obj, String path)

Description

save Serializable Object

License

Open Source License

Declaration

public static void saveSerializableObject(Object obj, String path) throws IOException 

Method Source Code

//package com.java2s;
/*/*from  w  ww . j a va  2  s.c o m*/
 * Copyright 2010
 * IBB-CEB - Institute for Biotechnology and Bioengineering - Centre of Biological Engineering
 * CCTC - Computer Science and Technology Center
 *
 * University of Minho 
 * 
 * This is free software: you can redistribute it and/or modify 
 * it under the terms of the GNU Public License as published by 
 * the Free Software Foundation, either version 3 of the License, or 
 * (at your option) any later version. 
 * 
 * This code is distributed in the hope that it will be useful, 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
 * GNU Public License for more details. 
 * 
 * You should have received a copy of the GNU Public License 
 * along with this code. If not, see http://www.gnu.org/licenses/ 
 * 
 * Created inside the SysBioPseg Research Group (http://sysbio.di.uminho.pt)
 */

import java.io.BufferedOutputStream;

import java.io.FileOutputStream;

import java.io.IOException;

import java.io.ObjectOutputStream;

public class Main {
    public static void saveSerializableObject(Object obj, String path) throws IOException {

        FileOutputStream fout = new FileOutputStream(path);
        BufferedOutputStream bout = new BufferedOutputStream(fout);
        ObjectOutputStream oos = new ObjectOutputStream(bout);

        try {
            oos.writeObject(obj);
        } finally {

            oos.flush();
            oos.close();
            bout.close();
            fout.close();
        }
    }
}

Related

  1. saveObjectToFile(Object obj, String fileName)
  2. saveObjectToPath(T objectToSave, String pathToSaveTo)
  3. saveParameters()
  4. saveResultToStream(ObjectOutputStream oos, Object result)
  5. saveResultToStream(ObjectOutputStream oos, Object result)
  6. saveSerialized(Serializable obj, File file)
  7. saveStringToFile(String filepath, String content)
  8. saveToFile(File f, Object obj)
  9. saveToFile(final File file, final Object obj)