Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.88 KB | None | 0 0
  1.  static void summaryPolicy()
  2.     {
  3.         Scanner input = new Scanner(System.in);
  4.         System.out.println("Show summary of policy.txt or archive.txt? Enter policy or archive");
  5.         String selection = input.next();
  6.         selection.toLowerCase();
  7.         while(!"policy".equals(selection) && !"archive".equals(selection))
  8.         {
  9.             System.out.println("Please enter policy or archive");
  10.             selection = input.next();
  11.             selection.toLowerCase();
  12.         }
  13.         if("policy".equals(selection))
  14.         {
  15.             try
  16.             {
  17.                 FileReader file = new FileReader("policy.txt");
  18.                 BufferedReader buffer = new BufferedReader(file);
  19.                 String s = "";
  20.                 while((s = buffer.readLine()) != null)
  21.                 {
  22.                     System.out.println(s);
  23.                     System.out.println("Total number of policies: " + getRowCountPolicy());
  24.                 }
  25.                 buffer.close();
  26.                    
  27.             }
  28.             catch(IOException error)
  29.             {
  30.                 System.out.println("File could not be read");
  31.             }
  32.         }
  33.         else if("archive".equals(selection))
  34.         {
  35.             try
  36.             {
  37.                 FileReader file = new FileReader("archive.txt");
  38.                 BufferedReader buffer = new BufferedReader(file);
  39.                 String s = "";
  40.                 while((s = buffer.readLine()) != null)
  41.                 {
  42.                     System.out.println(s);
  43.                    
  44.                 }
  45.                 System.out.println("Total number of policies: " + getRowCountArchive());
  46.                 buffer.close();
  47.                    
  48.             }
  49.             catch(IOException error)
  50.             {
  51.                 System.out.println("File could not be read");
  52.             }
  53.         }
  54.      
  55.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement