Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void search() throws FileNotFoundException, IOException{
- BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
- FileReader info=new FileReader("inventory.txt");
- BufferedReader file = new BufferedReader(info);
- String code, name, line, fileToSearch,opt,qty;
- System.out.println("♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦");
- System.out.println("→\t A. Search an item");
- System.out.println("♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦");
- System.out.println("→\t B. Display all");
- System.out.println("♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦♦");
- System.out.println("→\t Select Option[A/B]: ");
- opt=in.readLine();
- switch (opt){
- case "A":
- case "a":
- System.out.println("Input item code: ");
- fileToSearch=in.readLine();
- while((code=file.readLine())!= null){
- int indexFound=code.indexOf(fileToSearch);
- if(indexFound>-1){
- System.out.println("Equipment is existing✔");
- System.out.println("");
- System.out.println("ITEM CODE\t\tITEM NAME\t\t\tQUANTITY: ");
- line=code;
- System.out.println(line);
- }
- }
- break;
- case "B":
- case "b":
- //String line2;
- BufferedReader file2;
- //File inventory = new File("C:\Users\jaycee\Desktop\data\ENGINEERING-LABORATORY-INVENTORTY-APP\\inventory.txt");
- //if(!inventory.exists()){
- // inventory.createNewFile();
- //}
- file2=new BufferedReader(new FileReader("C:\\Users\\jaycee\\Desktop\\data\\ENGINEERING-LABORATORY-INVENTORTY-APP\\\\inventory.txt"));
- while((line=file2.readLine())!= null){
- System.out.println(line);
- }
- file2.close();
- break;
- default:
- System.out.println("Invalid input");
- break;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement