Here you can find the source of saveIndex(String path, Serializable obj)
static public boolean saveIndex(String path, Serializable obj)
//package com.java2s; //License from project: Open Source 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 String EXTENSION = "drivemandb"; private static String OS = System.getProperty("os.name").toLowerCase(); static public boolean saveIndex(String path, Serializable obj) { path += "." + EXTENSION; boolean res = true; File file = new File(path); if (file.exists() && file.isFile()) { if (file.delete()) { System.out.println("deleted ori index"); }/*from w w w . java 2 s . c o m*/ } FileOutputStream fos = null; try { fos = new FileOutputStream(path); ObjectOutputStream oos = new ObjectOutputStream(fos); oos.writeObject(obj); oos.close(); if (OS.indexOf("win") >= 0) { Runtime.getRuntime().exec("attrib +H " + path); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); res = false; } finally { try { if (fos != null) fos.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } return res; } }