-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCompare.java
88 lines (67 loc) · 2.31 KB
/
Compare.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
81
82
83
84
85
86
87
88
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.*;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.*;
public class Compare {
public static void main(String[] args) throws FileNotFoundException, ArrayIndexOutOfBoundsException
{
String line = "";
String splitBy = ",";
String[] register = null;
try
{
HashMap<String, String> map1 = new HashMap<>();
HashMap<String, String> map2 = new HashMap<>();
FileWriter writer=new FileWriter("/home/credentek/Result.csv");
BufferedReader br = new BufferedReader(new FileReader("/home/credentek/convertcsv.csv"));
while ((line = br.readLine()) != null) //returns a Boolean value
{
//System.out.println("Line: " +line);
register = line.split(splitBy); // use comma as separator
//System.out.println("Roll=" + register[0]);
//System.out.println(roll);
map1.put(register[0], register[1]+","+register[2]+","+register[3]+","+register[4]);
}
//System.out.println("Size of Map : "+map1);
br = new BufferedReader(new FileReader("/home/credentek/convertcsv1.csv"));
while ((line = br.readLine()) != null) //returns a Boolean value
{
//System.out.println("Line: " +line);
String[] payment = line.split(splitBy); // use comma as separator
//System.out.println("Roll=" + payment[0] + ", Name=" + payment[1]);
map2.put(payment[0], payment[1]);
}
for (String y : map1.keySet())
{
if (!map2.containsKey(y)) {
//System.out.println("Roll.no:" +y);
String val=map1.get(y);
System.out.println("The Value mapped to Key is:" +y+ " "+ val);
writer.append(y);
writer.append(val);
writer.append("\n");
System.out.println("Successful");
writer.flush();
}
}
writer.close();
}
catch (IOException e)
{
e.printStackTrace();
}catch(ArrayIndexOutOfBoundsException e)
{
System.out.println("ArrayIndexOutOfBounds Exception occurs");
e.printStackTrace();
} catch(NullPointerException e)
{
e.printStackTrace();
}
finally
{
}
}
}