I am parsing a file with more than 4M lines in it. It is of the form a^b^c^d^...^.... Now i want all the unique points(only the 1st two entries should be unique) from the file. So what I do is,
String str;
Set<String> lines = new LinkedHashSet<String>();
Set<String> set = Collections.synchronizedSet(lines);
String str1[] = str.split("\\^");
set.add(str1[0]+"^"+str1[1]);
So this gives me the unique 1st and 2nd unique points from the file. However, I also want the 3rd point(timestamp) i.e str1[2] associated with the above points. The new file should be of the form.
str1[0]^str1[1]^str1[2]
How do I go about doing this?