forked from vabburi82/Java8Examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestRead.java
More file actions
83 lines (70 loc) · 2.46 KB
/
TestRead.java
File metadata and controls
83 lines (70 loc) · 2.46 KB
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
81
82
83
package example1;
import java.io.*;
import java.util.*;
public class TestRead
{
public static void main(String[] args) throws IOException
{
File file;
Date d=new Date();
file = new File("C:/myfile.txt");
if (!file.exists())
{
file.createNewFile();
}
BufferedWriter bw =new BufferedWriter(new FileWriter(file,true));
PrintWriter pw = new PrintWriter(bw);
int i;
String name;
String email;
String phone;
Scanner input =new Scanner(System.in);
System.out.println("Welcome to Costumer Deatails page");
Customer names[]=new Customer[1000];
System.out.println("Are you creating a record:");
String userReply=input.next();
for (i = 0; "Y".equalsIgnoreCase(userReply); i++)
{
System.out.println("\nEnter Customer"+ "[" + i + "]"+ "details ::");
System.out.print("Enter the name: ");
name = input.next();
System.out.print("Enter the Email: ");
email = input.next();
System.out.print("Enter the PhoneNo: ");
phone = input.next();
System.out.println("\nDo you want to enter more customers : ");
userReply=input.next();
names[i]=new Customer();
names[i].name=name;
names[i].email=email;
names[i].phone=phone;
}
System.out.println("User Details Entered are ::\n");
pw.println("****************************");
pw.println(d.toString());
for(int j=0;j<i;j++)
{
System.out.println(d.toString());
System.out.println("Customer" + j+ "Details: ");
System.out.println("Name ::" + names[j].name);
System.out.println("Email :: "+ names[j].email);
System.out.println("Phone :: "+ names[j].phone);
System.out.println("================================");
pw.println("Customer" +"["+ j+"]"+ "Details: ");
pw.println("Name:"+ names[j].name);
pw.println("Email:"+names[j].email);
pw.println("Phone:"+names[j].phone);
pw.println("================================");
}
pw.close();
file = new File("C:/myfile.txt");
FileReader fr = new FileReader(file);
BufferedReader br = new BufferedReader(fr);
String line=br.readLine();
while(line!=null)
{
System.out.println(line);
line=br.readLine();
}
}
}