Search Results

Search found 8 results on 1 pages for 'battousai622'.

Page 1/1 | 1 

  • Java: Print and access List <String[]>

    - by battousai622
    Im reading in a file and storing it in t1. How do i access the elements in t1? When i try to print it i get addresses instead of values. Also whats the dif between string and string[]? CSVReader reader = new CSVReader(new FileReader("src/new_acquisitions.csv")); List <String[]> t1 = reader.readAll(); int i = 0 while(i < t1.size()) { System.out.println(t1.get(i)); i++; } output: [Ljava.lang.String;@9304b1 [Ljava.lang.String;@190d11 [Ljava.lang.String;@a90653 [Ljava.lang.String;@de6ced

    Read the article

  • Java: CSV file read & write.

    - by battousai622
    Im reading in 2 csv file: store_inventory & new_acquisitions... I want to be able to compare the store_inventory csv file with new_acquisitions. 1) If the item names match just update the quantity in store_inventory. 2) If new_acquisitions has a new item that does not exist in store_inventory, then add it to the store_inventory. Heres what i have so far but its not very good. I added comments where i need to add taks 1) & 2). Any advice or code would be great, thanks. File new_acq = new File("/src/test/new_acquisitions.csv"); Scanner acq_scan = null; try { acq_scan = new Scanner(new_acq); } catch (FileNotFoundException ex) { Logger.getLogger(mainpage.class.getName()).log(Level.SEVERE, null, ex); } String itemName; int quantity; Double cost; Double price; File store_inv = new File("/src/test/store_inventory.csv"); Scanner invscan = null; try { invscan = new Scanner(store_inv); } catch (FileNotFoundException ex) { Logger.getLogger(mainpage.class.getName()).log(Level.SEVERE, null, ex); } String itemNameInv; int quantityInv; Double costInv; Double priceInv; while (acq_scan.hasNext()) { String line = acq_scan.nextLine(); if (line.charAt(0) == '#') { continue; } String[] split = line.split(","); itemName = split[0]; quantity = Integer.parseInt(split[1]); cost = Double.parseDouble(split[2]); price = Double.parseDouble(split[3]); while(invscan.hasNext()) { String line2 = invscan.nextLine(); if (line2.charAt(0) == '#') { continue; } String[] split2 = line2.split(","); itemNameInv = split2[0]; quantityInv = Integer.parseInt(split2[1]); costInv = Double.parseDouble(split2[2]); priceInv = Double.parseDouble(split2[3]); if(itemName == itemNameInv) { //update quantity } } //add new entry into csv file } Thanks again for any help. =]

    Read the article

  • Java: Combine 2 List <String[]>

    - by battousai622
    I have two List of array string. I want to be able to create a New List (newList) by combining the 2 lists. But it must meet these 3 conditions: 1) Copy the contents of store_inventory into newList. 2) Then if the item names in store_inventory & new_acquisitions match, just add the two quantities together and change it in newList. 3) If new_acquisitions has a new item that does not exist in store_inventory, then add it to the newList. The titles for the CSV list are: Item Name, Quantity, Cost, Price. The List contains an string[] of item name, quantity, cost and price for each row. CSVReader from = new CSVReader(new FileReader("/test/new_acquisitions.csv")); List <String[]> acquisitions = from.readAll(); CSVReader to = new CSVReader(new FileReader("/test/store_inventory.csv")); List <String[]> inventory = to.readAll(); List <String[]> newList; Any code to get me started would be great! =] this is what i have so far... for (int i = 0; i < acquisitions.size(); i++) { temp1 = acquisitions.get(i); for (int j = 1; j < inventory.size(); j++) { temp2 = inventory.get(j); if (temp1[0].equals(temp2[0])) { //if match found... do something? //break out of loop } } //if new item found... do something? }

    Read the article

  • Java Swing: JTextArea columns question

    - by battousai622
    How do i put the text in specific columns with jTextArea? private javax.swing.JTextArea jTextArea1; jTextArea1.setColumns(4); jTextArea1.insert(price, 0); //column 1 jTextArea1.insert(cost, 0); //column 2 jTextArea1.insert(quantity, 0); //column ect.. jTextArea1.insert(itemName, 0); jTextArea1.insert("\n", 0);

    Read the article

  • Java SWING- Create a function to add elements to JScrollPanel ??? PLEASE

    - by battousai622
    I want to create a function so that i can call add JLables, ect inside the JScrollPanel. Im not sure what the command is in netbeans. I tried doing JScrollPanel - events - container - componentAdded to create the code below. But nothing shows up when i add code to that function. Any help would be great please! =] private void initComponents() { scrollPanel = new javax.swing.JScrollPane(); scrollPanel.addContainerListener(new java.awt.event.ContainerAdapter() { public void componentAdded(java.awt.event.ContainerEvent evt) { scrollPanelComponentAdded(evt); } } private void scrollPanelComponentAdded(java.awt.event.ContainerEvent evt) { System.out.println("main"); }

    Read the article

  • Java Swing- Create a function to add elements to JScrollPanel

    - by battousai622
    I want to create a function so that i can call add JLabel's, etc inside the JScrollPanel. I am not sure what the command is in NetBeans. I tried doing JScrollPanel - events - container - componentAdded to create the code below. But nothing shows up when i add code to that function. private void initComponents() { scrollPanel = new javax.swing.JScrollPane(); scrollPanel.addContainerListener(new java.awt.event.ContainerAdapter() { public void componentAdded(java.awt.event.ContainerEvent evt) { scrollPanelComponentAdded(evt); } } private void scrollPanelComponentAdded(java.awt.event.ContainerEvent evt) { System.out.println("main"); } Any help would be great, thanks.

    Read the article

1