Guest User

Untitled

a guest
Jul 16th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1. package project3sgrant;
  2.  
  3. import java.io.*;
  4. import java.util.*;
  5.  
  6.  
  7. public class ReadFile
  8. {
  9.  
  10. /**
  11. * This is an application that reads data from a sequential file
  12. * and outputs the data to the screen
  13. * @param String containing name of file to be read
  14. */
  15.  
  16. public static void main(String[] args) throws IOException
  17. {
  18. String outString;
  19. BufferedReader input;
  20. DataOutputStream output;
  21.  
  22.  
  23. input= new BufferedReader(new FileReader("States.Fall2009.txt"));
  24.  
  25. /*
  26. this is the loop to continue until an eof is found
  27. note: that this is the equivalent of a priming and a loop read
  28. The file is read and the data read is placed in outstring
  29. As long as outstring is not null the loop will continue!
  30. */
  31. while ((outString=getData(input))!=null)
  32. {
  33. StringTokenizer st = new StringTokenizer(outString);
  34.  
  35. String Name = st.nextToken();
  36. String Capital = st.nextToken();
  37. String Abbreviation = st.nextToken();
  38. String Population = st.nextToken();
  39. String Region = st.nextToken();
  40. String Number = st.nextToken();
  41.  
  42. System.out.println("State: " + Name);
  43. System.out.println("Capital: " + Capital);
  44. System.out.println("Abbreviation: " + Abbreviation);
  45. System.out.println("Population: " + Population);
  46. System.out.println("Region: " + Region);
  47. System.out.println("Region Number: " + Number);
  48.  
  49. String stateName, stateCapital, stateAbbreviation, statePopulation,
  50. stateRegion, stateNumber;
  51.  
  52.  
  53. }
  54.  
  55. // close the input file...
  56. input.close();
  57.  
  58. System.out.println("all done");
  59.  
  60.  
  61. }// end main()
Add Comment
Please, Sign In to add comment