Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- So I have a file named Order.txt. Below are the info inside the text file.
- Order ID:Item ID:Item Name:Item Price:Qty:Total Price:User ID:Status:
- 0:3:mee goreng:7.00:1:7.0:TP054120:Processing:
- 1:3:mee goreng:7.00:1:7.0:TP054120:Processing:
- 2:2:fried rice:8.00:1:8.0:TP054120:Processing:
- 3:3:mee goreng:7.00:1:7.0:TP054120:Pending:
- I am trying to insert line where Status == "Processing" only. But I dont know how to do it. I have done my code but it insert all of the lines to jTable.
- try{
- try (FileReader odR = new FileReader(od); BufferedReader odBR = new BufferedReader(odR)) {
- String [] colHeaders = odBR.readLine().trim().split(":");
- DefaultTableModel model = (DefaultTableModel) tbOrder.getModel();
- model.setColumnIdentifiers(colHeaders);
- model.setRowCount(0);
- Object[] tableLines = odBR.lines().toArray();
- for (Object tableLine : tableLines) {
- String line = tableLine.toString().trim();
- String[] row = line.split(":");
- model.addRow(row);
- }
- }
- }catch (IOException ex) {
- Logger.getLogger(manageMenu.class.getName()).log(Level.SEVERE, null, ex);
- }
Advertisement
Add Comment
Please, Sign In to add comment