This content has been marked as final. Show 7 replies
The explanation of the problem is not clear.
Provide an example of file1 and file2 distinct and different.
For each file provide the lines that match and lines that do not match.
Then provide an explanation of what a match means and/or what a non-match means.
And don't use the same character (comma) both for the input and output. Doing so confuses what is just a separator and what is part of the data.
Vicky wrote:You probably just need a single data-structure (A Map<String,List<String>>)
basically all files containt key,value pair entries
i want all common key with
values in a file in this case it is tom
read file1 , populate the map with it's values .
So the map looks like
tim -> chase
tom -> jerry
after reading file1 in your example.
read files 2-N . If the file contains a key not in the map , ignore that pair . Else add the value to the list referenced by the key.
So after reading file2 , the map will contain
tim -> chase
the key vinay is ignored .
After you have read all files , discard the entries in the map which do not correspond to a list of size N .
Vicky wrote:unless you change file1 , file3 and file4 to include the key vinay , you won't have it as common to all files . Or I don't understand your requirement :) .
I think it quite imcomplete my intention is to get all commonkeys present in all 4 files, so lets if i leave vinay key as u mentioned and what if i add 5th file tommorow and it has vinay that time this will not work
What do you need -
Keys that occur in every file - so common to all files ?
Keys that occur in more than 1 file ?