I have a .txt file with integers on each line e.g.
1 4 5 6
I want to count the occurences of the values that are in an array with the file.
My code extract is this
String s = null; FileReader fr = new FileReader(file); BufferedReader br = new BufferedReader(fr); while ((s = br.readLine()) !=null) { StringTokenizer st = new StringTokenizer(s); while (st.hasMoreTokens()) { for (int i = 0; i < array.length; i++) { if (st.nextToken().equals(array[i])) { count++; }Error Messages are java.util.NoSuchElementException at java.util.StringTokenizer.nextToken(Unknown Source)
The file is in the same directory.
Could someone please give me a hand? Thanks