public ItemCollection parse() {
        int cap = -1;
        ArrayList<Item> items = new ArrayList<Item>();

        try {
            BufferedReader br = new BufferedReader(new FileReader(file));
            String line;
            boolean first = true;
            while ((line = br.readLine()) != null) {
                // process the line.
                String[] strArr = line.split(",");
                if (first) {
                    cap = Integer.parseInt(strArr[0]);
                    first = false;
                } else {
                    int weight = Integer.parseInt(strArr[0]);
                    int value = Integer.parseInt(strArr[1]);
                    String name = strArr[2];
                    Item temp = new Item(weight, value, name);
                    items.add(temp);
                }
            }
            br.close();
        } catch (FileNotFoundException ex) {
            Logger.getLogger(CSVParser.class.getName()).log(Level.SEVERE, null, ex);
        } catch (Exception e) {
            System.err.println("An error ocurred while processing the CSV file!");
        }

        ItemCollection ic = new ItemCollection(items, cap);
        return ic;
    }