Advertisement
Unit2

Untitled

Feb 23rd, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.01 KB | None | 0 0
  1.         try {
  2.            
  3.             BufferedReader br = new BufferedReader(new FileReader(file));
  4.            
  5.             System.out.println("\nFile Opened Successfully.");
  6.            
  7.             Scanner scanner = new Scanner(file);
  8.            
  9.             Node root = null;
  10.            
  11.             // Loops through file until EOF
  12.             while(scanner.hasNext())
  13.             {
  14.                 // Scans the line
  15.                 String data = scanner.nextLine();
  16.                
  17.                 // Makes a string to read the letter which is the function
  18.                 String letter = data.replaceAll("[0-9]", "");
  19.                
  20.                 // Makes a string to read the numbers
  21.                 String numbers = data.replaceAll("[a-zA-Z] ", "");
  22.                
  23.                 int numInput = Integer.parseInt(numbers);
  24.                
  25.                 if(letter.equals("i"))
  26.                 {
  27.                     System.out.println("Insert function");
  28.                 }
  29.                
  30.                 if(letter.equals("d"))
  31.                 {
  32.                     System.out.println("Delete function");
  33.                 }
  34.                 if(letter.equals("q"))
  35.                 {
  36.                     System.out.println("Quit function");
  37.                 }
  38.  
  39.             }
  40.            
  41.             // Closes text file
  42.             br.close();
  43.             scanner.close();
  44.         }
  45.         catch (Exception e) {
  46.             e.printStackTrace();
  47.         }
  48.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement