Problem : How you can save(serialize) an object to Hard Disk or send it to network ?
Solution :
Program :Step 1 - CodingCreate a text file c:/sunilos/Employee.java and copy below contents. import java.io.Serializable; /** * A program to implement Serializable interface. */ public class Employee implements Serializable{ private int id; private String firstName; private String lastName; private transient String tempValue; public Employee(){ //Default Constructor } public Employee(int id,String firstName, String lastName){ this.id=id; this.firstName=firstName; this.lastName=lastName; } public int getId() { return id; } public void setId(int id) { this.id = id; } public String getFirstName() { return firstName; } public void setFirstName(String firstName) { this.firstName = firstName; } public String getLastName() { return lastName; } public void setLastName(String lastName) { this.lastName = lastName; } public Address getAdd() { return add; } public void setAdd(Address add) { this.add = add; } public String getTempValue() { return tempValue; } public void setTempValue(String tempValue) { this.tempValue = tempValue; } } Step 2 - Deployment
|