Hi I have been given an asignment to read a file and determine the cyclomatic complexity I have tried a few variations but cant seem to get the program to count the 'if','while' etc it always gives 1 as result
does anyone know how to do this
I would really appreciate any help below is 1 of the codes I have tried

import java.io.*;
import java.util.*;

public class complexity {
static BufferedReader keyboard=new
BufferedReader(new InputStreamReader(System.in));
static PrintWriter screen = new PrintWriter(System.out, true);
public static void main(String[] args) throws IOException {

String[] keywords = {"if","while","switch","for"};
int complexity = 1;
String fileName;

screen.println("Enter the Java file to be read: ");

fileName = new String(keyboard.readLine());

FileInputStream fs = new FileInputStream(fileName);
InputStreamReader r = new InputStreamReader(fs);
StreamTokenizer parser = new StreamTokenizer(r);

while ( parser.nextToken() != StreamTokenizer.TT_EOF )
if ( parser.ttype == StreamTokenizer.TT_WORD)

for(int i=0; i<keywords.length; i++)

if ((parser.sval).equals(keywords))
complexity ++;
screen.println("complexity = : "+complexity);