Code example for ObjectInputStream

Methods: closereadObject

0
 
		Object o = null;
 
		try { 
			FileInputStream fis = new FileInputStream(filename);
			ObjectInputStream in = new ObjectInputStream(fis);
			o = in.readObject();
			in.close();
		} catch (IOException e) {
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} 
		return (Company) o;
	} 
 
	/** 
	 * Write (say, serialize) a company. 
	 */ 
	public static boolean writeCompany(Company c, String filename) {
Experience pair programming with AI  Get Codota for Java