I want to write objects to a file... how can I do that????
What addition should I do to get an object say o1 of the getData function???/**
* Write a description of class TDMS here.
*
* @author (your name)
* @version (a version number or a date)
*/
import java.io.*;
public class TDMS
{
long rec_id;
String person_name;
String d_o_b;
String res_adress;
int res_pincode;
long res_phoneno;
int res_faxno;
String occupation;
String companyName;
String officeAddress;
int officePinCode;
long officePhoneno;
long officeFax;
String emailId;
String internetAdress;
public TDMS()
{
rec_id=0;
person_name=" ";
d_o_b=" ";
res_adress=" ";
res_pincode=0;
res_phoneno=0;
res_faxno=0;
occupation=" ";
companyName=" ";
officeAddress=" ";
officePinCode=0;
officePhoneno=0;
officeFax=0;
emailId=" ";
internetAdress=" ";
}
public void get_data()throws IOException
{
rec_id++;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter your name: ");
person_name=br.readLine();
System.out.print("Enter your date of birth(dd/mm/yy): ");
d_o_b=br.readLine();
System.out.print("Enter your residential address: ");
res_adress=br.readLine();
System.out.print("Enter your residential pincode: ");
res_pincode=Integer.parseInt(br.readLine());
System.out.print("Enter your residential phone number: ");
res_phoneno=Integer.parseInt(br.readLine());
System.out.print("Enter your residential fax number: ");
res_faxno=Integer.parseInt(br.readLine());
System.out.print("Enter your occupation: ");
occupation=br.readLine();
System.out.print("Enter your company name: ");
companyName=br.readLine();
System.out.print("Enter your office adress: ");
officeAddress=br.readLine();
System.out.print("Enter your office pin code: ");
officePinCode=Integer.parseInt(br.readLine());
System.out.print("Enter your office phone number: ");
officePhoneno=Integer.parseInt(br.readLine());
System.out.print("Enter your office fax: ");
officeFax=Integer.parseInt(br.readLine());
System.out.print("Enter your e-mail ID: ");
emailId=br.readLine();
System.out.print("Enter your web address: ");
internetAdress=br.readLine();
}
public void show_data()
{
System.out.println("Record ID: "+rec_id);
System.out.println("Name :"+person_name);
System.out.println("Date of Birth: "+d_o_;
System.out.println("Residential address: "+res_adress);
System.out.println("Residential pin code: "+res_pincode);
System.out.println("Residential phone number: "+res_phoneno);
System.out.println("Residential fax number: "+res_faxno);
System.out.println("Occupation: "+occupation);
System.out.println("Company name: "+companyName);
System.out.println("Office adress: "+officeAddress);
System.out.println("Office pin code: "+officePinCode);
System.out.println("Office phone number: "+officePhoneno);
System.out.println("Office fax: "+officeFax);
System.out.println("E-Mail ID: "+emailId);
System.out.println("Web adress: "+internetAdress);
}
}