I have a text file. Sample content of that particular text file is like
root(ROOT-0, good-4)nn(management-2, company-1)nsubj(good-4, management-2)
Now i need to separate this and store it in ArrayList. For that i write the following code
public class subject {
public void getsub(String f){
ArrayList <String>ar=new ArrayList<String>();
String a="[a-z]([a-z]-[0-9],[a-z]-[0-9])";
Pattern pattern=Pattern.compile(a);
Matcher matcher=pattern.matcher(f);
while(matcher.find()){
if(matcher.find()){
ar.add(matcher.group(0));
}
}
System.out.println(ar.size());
for(int i=0;i<ar.size();i++){
System.out.println(ar.get(i));
}
}
}
but arraylist is not getting populated. Why is that so