Subversion Repositories SmartDukaan

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
17 naveen 1
/**
2
 * 
3
 */
4
package in.shop2020.metamodel.util;
5
 
6
import java.io.File;
7
import java.io.FileInputStream;
8
import java.io.FileOutputStream;
9
import java.io.ObjectInputStream;
10
import java.io.ObjectOutputStream;
11
 
12
/**
13
 * @author naveen
14
 *
15
 */
16
public class DBUtils {
17
 
18
	/**
19
	 * 
20
	 * @param objectToStore
21
	 */
22
	public static void store(Object objectToStore, String dbFile) throws Exception {
23
		System.out.println("store()");
24
 
25
		FileOutputStream fos = new FileOutputStream(new File(dbFile));
26
		ObjectOutputStream out = new ObjectOutputStream(fos);
27
 
28
		out.writeObject(objectToStore);
29
		out.close();
30
		System.out.println("Serialization complete");
31
	}
32
 
33
	/**
34
	 * 
35
	 */
36
	public static Object read(String dbFile) throws Exception {
37
		System.out.println("read()");
38
 
39
		FileInputStream fis = new FileInputStream(new File(dbFile));
40
		ObjectInputStream in = new ObjectInputStream(fis);
41
		Object obj = in.readObject();
42
		in.close();
43
 
44
		System.out.println("De-serialization complete");
45
		return obj;
46
	}
47
}