I'm really stucked on this problem. I'm not sure if this logic is possible, is there any other whay to achieve what I want?
I'm creating a HashMap like this.
List<String> data1 = new ArrayList();
data1.add("valid1");
data1.add("valid2");
List<String> data2 = new ArrayList();
data2.add("valid3");
data2.add("valid4");
Map<String,ArrayList> hashList = new HashMap();
hashList.put("one",data1);
hashList.put("two",data2);
So the Output will be like this:
{one=[valid1,valid2], two=[valid3,valid4]}
But what am I doing is, i'm reading a file and compare it to hashmap
Code:
String line;
String[] token;
try {
LineIterator it = FileUtils.lineIterator(file,"UTF-8");
while(it.hasNext()){
line = it.nextLine();
token = StringUtils.split(line,(","));
if(token[1].equalsIgnoreCase( //check if its equal to the value of the hashmap){
System.out.println("Valid");
}
}
}
my file looks like this :
test1,valid1,check1
test2,valid3,check2
So what I want to do is, to check if the "token[1]" is valid to the value of hashmap.
Thank you in advance!
Map<String,ArrayList>You might want to avoid the raw list type.token[1]is equal to any of the items in any of theArrayLists?