Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package project3sgrant;
- import java.io.*;
- import java.util.*;
- public class ReadFile
- {
- /**
- * This is an application that reads data from a sequential file
- * and outputs the data to the screen
- * @param String containing name of file to be read
- */
- public static void main(String[] args) throws IOException
- {
- String outString;
- BufferedReader input;
- DataOutputStream output;
- input= new BufferedReader(new FileReader("States.Fall2009.txt"));
- /*
- this is the loop to continue until an eof is found
- note: that this is the equivalent of a priming and a loop read
- The file is read and the data read is placed in outstring
- As long as outstring is not null the loop will continue!
- */
- while ((outString=getData(input))!=null)
- {
- StringTokenizer st = new StringTokenizer(outString);
- String Name = st.nextToken();
- String Capital = st.nextToken();
- String Abbreviation = st.nextToken();
- String Population = st.nextToken();
- String Region = st.nextToken();
- String Number = st.nextToken();
- System.out.println("State: " + Name);
- System.out.println("Capital: " + Capital);
- System.out.println("Abbreviation: " + Abbreviation);
- System.out.println("Population: " + Population);
- System.out.println("Region: " + Region);
- System.out.println("Region Number: " + Number);
- String stateName, stateCapital, stateAbbreviation, statePopulation,
- stateRegion, stateNumber;
- }
- // close the input file...
- input.close();
- System.out.println("all done");
- }// end main()
Add Comment
Please, Sign In to add comment