Advertisement
Guest User

ur welcome

a guest
Jan 17th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. static void readFromFile(String file, int option)
  2. {
  3. //variables that are used to read the file into the computer
  4. int total = 0;
  5. int monthTotal = 0;
  6. int jan = 0;
  7. int feb = 0;
  8. int mar = 0;
  9. int apr = 0;
  10. int may = 0;
  11. int jun = 0;
  12. int jul = 0;
  13. int aug = 0;
  14. int sep = 0;
  15. int oct = 0;
  16. int nov = 0;
  17. int dec = 0;
  18. String month = " ";
  19. String search = " ";
  20.  
  21. //sees which option the client is coming from
  22.  
  23. if (option == 2)
  24. {
  25. System.out.println("Please enter the abreviated foorm of the month you want e.g. Jul");
  26. month = keyboard.next().toLowerCase();
  27. while (!(month.equals ("jan") || month.equals ("feb") || month.equals ("mar") || month.equals ("apr") || month.equals ("may") || month.equals ("jun") || month.equals ("jul") || month.equals ("aug") || month.equals ("sep") || month.equals ("oct") || month.equals ("nov") || month.equals ("dec")));
  28. {
  29. System.out.println("Invalid entry please try again");
  30. month = keyboard.next().toLowerCase();
  31. }
  32.  
  33. }// end of if
  34. else if (option == 3)
  35. {
  36. System.out.println("Please enter search");
  37. search = keyboard.next().toLowerCase();
  38. }//end of else if
  39.  
  40. try
  41. {
  42. File currentFile = new File (file);
  43. FileReader fReader = new FileReader(currentFile);
  44. LineNumberReader lnr = new LineNumberReader(fReader);
  45. if (currentFile.exists())
  46. {
  47. while (lnr.readLine() !=null)
  48. {
  49. total++;
  50. }
  51.  
  52. }
  53. else
  54. {
  55. System.out.println("File does not exist");
  56. }
  57. }catch (IOException e) {}//end of try
  58. }//end of read from file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement