Here you can find the source of serialize(String path, String name, Object obj)
public static void serialize(String path, String name, Object obj)
//package com.java2s; //License from project: Apache License import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.ObjectOutputStream; import java.io.Serializable; public class Main { public static void serialize(String path, String name, Object obj) { checkPath(path);/*w w w. j av a 2s.c o m*/ if (!(obj instanceof Serializable)) { return; } ObjectOutputStream oos = null; try { oos = new ObjectOutputStream(new FileOutputStream(path + name)); oos.writeObject(obj); oos.flush(); } catch (IOException e) { e.printStackTrace(); } finally { if (oos != null) { try { oos.close(); } catch (IOException e) { e.printStackTrace(); } } } } private static void checkPath(String path) { File pathFile = new File(path); if (!pathFile.exists()) { pathFile.mkdirs(); } } }