-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathModle.java
80 lines (70 loc) · 1.57 KB
/
Modle.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import java.io.*;
public class Modle
{
String member_name;
String gender;
String dob;
String age;
String phoneno;
Modle()
{
}
Modle(String a, String b,String c, String d, String e)
{
this.member_name = a;
this.gender = b;
this.dob = c;
this.age = d;
this.phoneno = e;
}
public String toString()
{
return "Member Name : "+this.member_name+"Gender : "+this.gender+ "Date Of Birth = "+this.dob+" Age: "+this.age+" Phone No :"+this.phoneno;
}
public String writeInFile()
{
return this.member_name+","+this.gender+","+this.dob+","+this.age+","+this.phoneno;
}
public void saveObject(String fileName) throws IOException
{
File f = new File(fileName);
System.out.println(f.exists());
if(f.exists())
{
FileWriter fw = new FileWriter(fileName,true);
fw.write("\n"+this.writeInFile());
fw.close();
}
else
{
FileWriter fw = new FileWriter(fileName);
fw.write(this.writeInFile());
fw.close();
}
}
/*public void readObject(String fileName) throws IOException
{
File f = new File(fileName);
System.out.println(f.exists());
if(f.exists())
{
FileReader fr = new FileReader("customer.txt");
char ch[] = new char[1000];
fr.read(ch);
fr.close();
String myStr = String.valueOf(ch);
String data[] = myStr.split("\n");
Modle cus[] = new Modle[data.length];
for(int i=0;i<data.length;i++)
{
String attr[] = data[i].split(",");
cus[i] = new Modle(attr[0],attr[1],attr[2],attr[3]);
}
for(int i=0;i<cus.length;i++)
{
System.out.println(cus[i]);
}
}
}
*/
}