WordsFrequency

WordsFrequency - /* B Bernadette Lurch The goal of this...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
/* Bernadette Lurch B The goal of this program is to read text from an input file and isolate each word. Then count the frequency that each word occurs. T THE MAIN CALLS A METHOD IN THE WORDLIST CLASS TO ADD A TOKEN. ...... Static call syntax: className.methodName( arguments ) s 1. 1 */ * import java.io.*; import java.util.*; import java.lang.*; i public class WordsFrequency{ p public static void main(String[] args){ p Scanner console = new Scanner(System.in); try {Scanner in = new Scanner(new File("TextIn.txt")); PrintStream out = new PrintStream(new File("WordsReport.txt")); int nextFreePosition = 0; //WHAT DOES THIS DO?!!?!? //String [] tokenArray = new String[10000]; DONT WANT THIS. NEED ARRAYLIST while(in.hasNext()) { String token = in.next(); // only deal with letters and digits and lowercase token = token.toLowerCase(); token = areLettersOrDigits(token); //OR USE SPECIAL CONSTRUCTOR OF StringTokenizer // StringTokenizer st = new StringTokenizer(token, ",/$<>?!.\;`"); // StringTokenizer st = new StringTokenizer(token, ",/$<>?!.\""); nextFreePosition = addWord(tokenArray, token, nextFreePosition);
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 06/07/2010 for the course CS 201 taught by Professor Staff during the Spring '08 term at Iona.

Page1 / 2

WordsFrequency - /* B Bernadette Lurch The goal of this...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online