Subversion Repositories SmartDukaan

Rev

Rev 18 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 18 Rev 21
Line 23... Line 23...
23
	 * @param dbFile
23
	 * @param dbFile
24
	 * @throws Exception
24
	 * @throws Exception
25
	 */
25
	 */
26
	public static void store(Object objectToStore, String dbFile) 
26
	public static void store(Object objectToStore, String dbFile) 
27
		throws Exception {		
27
		throws Exception {		
-
 
28
		File f = new File(dbFile);
-
 
29
		if(!f.exists()) {
-
 
30
			f.createNewFile();
-
 
31
		}
-
 
32
		
28
		FileOutputStream fos = new FileOutputStream(new File(dbFile));
33
		FileOutputStream fos = new FileOutputStream(f);
29
		ObjectOutputStream out = new ObjectOutputStream(fos);
34
		ObjectOutputStream out = new ObjectOutputStream(fos);
30
		
35
		
31
		out.writeObject(objectToStore);
36
		out.writeObject(objectToStore);
32
		out.close();
37
		out.close();
33
		Utils.logger.info("Serialization complete");
38
		Utils.logger.info("Serialization complete");
Line 38... Line 43...
38
	 * @param dbFile
43
	 * @param dbFile
39
	 * @return
44
	 * @return
40
	 * @throws Exception
45
	 * @throws Exception
41
	 */
46
	 */
42
	public static Object read(String dbFile) throws Exception {
47
	public static Object read(String dbFile) throws Exception {
-
 
48
		File f = new File(dbFile);
-
 
49
		if(!f.exists()) {
-
 
50
			return null;
-
 
51
		}
-
 
52
		
43
		FileInputStream fis = new FileInputStream(new File(dbFile));
53
		FileInputStream fis = new FileInputStream(f);
44
		ObjectInputStream in = new ObjectInputStream(fis);
54
		ObjectInputStream in = new ObjectInputStream(fis);
45
		Object obj = in.readObject();
55
		Object obj = in.readObject();
46
		in.close();
56
		in.close();
47
		
57
		
48
		Utils.logger.info("De-serialization complete");
58
		Utils.logger.info("De-serialization complete");