thank you for your help. i tried your code and got one error and i was hoping you could tell me where i have gone wrong.
i get the following error:-
H:\qp&e\halstead.java:45: ')' expected
if (Arrays.binarySearch(words), currToken) > -1)
^
1 error
Finished
here is the code so far:-
import java.io.*;
import java.util.*;
import java.util.StringTokenizer;
class halstead{
//for keyboard input
static BufferedReader keyboard = new BufferedReader(new
InputStreamReader(System.in));
//for screen output
static PrintWriter screen = new PrintWriter(System.out, true);
//main method - first method to be executed
public static void main(String[]args)throws IOException{
String line = null;
String file;
String[] words = { "ADDHANDLER", "ADDRESSOF", "ANDALSO", "ALIAS", "AND" };
//use screen object (class PrintWriter) to display
//string on screen
screen.print("enter the name of the file to be read: ");
screen.flush();
file = new String(keyboard.readLine());
//a bufferedreader object that takes a stream of characters
//from the fileraeader object and sends a string into
//the program
BufferedReader reader = new BufferedReader(new FileReader(file));
//the bufferedreader method readline() reads from the
//character stream to program a line of characters
line = reader.readLine();
//while loop where readline method returns a null value when
//the end of the file is reached
while (line!= null)
{
//decleration of string tokenizer
//used to seperate each
word for comparison to terms specified
StringTokenizer words = new StringTokenizer(line);
Arrays.sort(words);
String currToken = words.nextToken();
if (Arrays.binarySearch(words), currToken) > -1)
++count;
line = reader.readLine();
}
}
}