-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIn_Lab_1_Chandu_Address.java
More file actions
62 lines (58 loc) · 1.65 KB
/
In_Lab_1_Chandu_Address.java
File metadata and controls
62 lines (58 loc) · 1.65 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
package Lab_3;
import java.io.*;
import java.io.FileNotFoundException;
import java.io.BufferedReader;
import java.util.ArrayList;
public class In_Lab_1_Chandu_Address {
public static void main(String Args[])
{
try {
FileReader F_name = new FileReader("C:\\Users\\121de\\OneDrive\\Desktop\\Java\\Swing\\src\\Lab_3\\Name.txt");
BufferedReader name = new BufferedReader(F_name);
//Reading Address.txt//
FileReader F_add = new FileReader("C:\\Users\\121de\\OneDrive\\Desktop\\Java\\Swing\\src\\Lab_3\\Address.txt");
BufferedReader add = new BufferedReader(F_add);
String S_name,S_add;
// String [] res_name= {};
// String [] res_add= {};
ArrayList<String> nameList = new ArrayList<>();
ArrayList<String> addList = new ArrayList<>();
while((S_name = name.readLine())!=null)
{
// String res_name. S_name.split("\n");
nameList.add(S_name);
}
F_name.close();
while((S_add = add.readLine())!=null)
{
addList.add(S_add);
}
F_add.close();
for(int i = 0;i<nameList.size();i++)
{
String nam1 = nameList.get(i);
String add1 = addList.get(i);
String [] nam2 = nam1.split("\t");
String [] add2 = add1.split("\t");
for(int j =0;j<nam2.length-1;j+=2)
{
if(nam2[j].equals(add2[j]))
{
String s= "Id: "+nam2[j]+"\nName: "+nam2[j+1]+"\nAddress: "+add2[j+1];
System.out.println(s);
}
// System.out.println("Id: "+nam2[j]+"\nName: "+nam2[j+1]+"\nAddress: "+add2[j+1]);
}
}
}
catch(FileNotFoundException e)
{
System.out.println("File Not Found "+e.getMessage());
}
catch(IOException i)
{
i.printStackTrace();
}
}
//Reading both files
}