I\'m writing a project that captures Java keywords from a .java file and keeps track of the occurrences with a map. I\'ve used a similar method in the past successfully, but
Map map = new HashMap();
Set keywordSet = new HashSet(Arrays.asList(keywords));
Scanner input = new Scanner(file);
while (input.hasNext()){
String key = input.next();
if (key.length() > 0)
if (keywordSet.contains(key)){
Integer counter = map.get(key);
if (counter == null)
map.put(key, 1);
else
map.put(key, count + 1);
}
}