Here you can find the source of saveSerializableObject(Object obj, String path)
public static void saveSerializableObject(Object obj, String path) throws IOException
//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(); } } }