Example of String Tokenizer… while ((state=getData(input))!= null)//reads text file line by line { StringTokenizer st = new StringTokenizer(state); while (st.hasMoreTokens())//parses fields and assigns to variables { stName = st.nextToken(); stCapital = st.nextToken(); stAbbreviation = st.nextToken(); stPopulation = st.nextToken(); stRegion = st.nextToken(); stNumber = st.nextToken(); }//end while int intPopulation = Integer.parseInt(stPopulation);Used Buffered Reader in lieu of Scanner objects. //prompts user for two character state abbreviattion to search objects InputStreamReader reader = new InputStreamReader(System.in); BufferedReader keyboard = new BufferedReader(reader); try { System.out.print("To search the state records, please enter" + " the 2 character state abbreviation (i.e. TX): "); stateInputAbb = keyboard.readLine( ); System.out.println(); } catch (IOException e) { }Static Use private static int count = 0;… /** * Static Method - returns static count of number of objects created * @return count*/ public static int getCount() { return count;
View Full Document