Subversion Repositories SmartDukaan

Rev

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

Rev 49 Rev 64
Line 1... Line 1...
1
/**
1
/**
2
 * 
2
 * 
3
 */
3
 */
4
package in.shop2020.metamodel.util;
4
package in.shop2020.util;
5
 
5
 
6
import in.shop2020.util.Utils;
-
 
7
 
6
 
8
import java.io.File;
7
import java.io.File;
9
import java.io.FileInputStream;
8
import java.io.FileInputStream;
10
import java.io.FileOutputStream;
9
import java.io.FileOutputStream;
11
import java.io.ObjectInputStream;
10
import java.io.ObjectInputStream;
Line 47... Line 46...
47
		}
46
		}
48
		Utils.info("Serialization complete");
47
		Utils.info("Serialization complete");
49
	}
48
	}
50
	
49
	
51
	/**
50
	/**
-
 
51
	 * 
-
 
52
	 * @param text
-
 
53
	 * @param dbFile
-
 
54
	 * @throws Exception
-
 
55
	 */
-
 
56
	public static void store(String text, String filename) 
-
 
57
		throws Exception {		
-
 
58
		File f = new File(filename);
-
 
59
		if(!f.exists()) {
-
 
60
			f.createNewFile();
-
 
61
		}
-
 
62
		
-
 
63
		ObjectOutputStream out = null;
-
 
64
		try {
-
 
65
			FileOutputStream fos = new FileOutputStream(f);
-
 
66
			fos.write(text.getBytes());
-
 
67
		}
-
 
68
		finally {
-
 
69
			if(out != null) {
-
 
70
				out.close();
-
 
71
			}
-
 
72
		}
-
 
73
		Utils.info("Text writing is complete");
-
 
74
	}
-
 
75
	/**
52
	 * Retrieves serialised object from given file
76
	 * Retrieves serialised object from given file
53
	 * 
77
	 * 
54
	 * @param dbFile
78
	 * @param dbFile
55
	 * @return De-serialised object
79
	 * @return De-serialised object
56
	 * @throws Exception
80
	 * @throws Exception