Code example for ObjectInputStream

Methods: closereadObject

0
 
public class OOSSerializer implements ObjectSerializer { 
 
	public Object readObject(File f) throws IOException {
		try { 
			ObjectInputStream ois = new ObjectInputStream(new FileInputStream(f));
			Object o = ois.readObject();
			ois.close();
 
			return o;
		} 
		catch (ClassNotFoundException e) {
			return null; 
		} 
	} 
 
	public void writeObject(File f, Serializable o, boolean force) throws IOException {
		FileOutputStream fos = new FileOutputStream(f);
		fos.getChannel().force(force);
 
Stop searching for code, let great code find you!  Add Codota to your java IDE