Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static void readFromFile(String file, int option)
- {
- //variables that are used to read the file into the computer
- int total = 0;
- int monthTotal = 0;
- int jan = 0;
- int feb = 0;
- int mar = 0;
- int apr = 0;
- int may = 0;
- int jun = 0;
- int jul = 0;
- int aug = 0;
- int sep = 0;
- int oct = 0;
- int nov = 0;
- int dec = 0;
- String month = " ";
- String search = " ";
- //sees which option the client is coming from
- if (option == 2)
- {
- System.out.println("Please enter the abreviated foorm of the month you want e.g. Jul");
- month = keyboard.next().toLowerCase();
- 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")));
- {
- System.out.println("Invalid entry please try again");
- month = keyboard.next().toLowerCase();
- }
- }// end of if
- else if (option == 3)
- {
- System.out.println("Please enter search");
- search = keyboard.next().toLowerCase();
- }//end of else if
- try
- {
- File currentFile = new File (file);
- FileReader fReader = new FileReader(currentFile);
- LineNumberReader lnr = new LineNumberReader(fReader);
- if (currentFile.exists())
- {
- while (lnr.readLine() !=null)
- {
- total++;
- }
- }
- else
- {
- System.out.println("File does not exist");
- }
- }catch (IOException e) {}//end of try
- }//end of read from file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement