I have a string (taken from file):
Computer: intel, graphic card: Nvidia,
Mouse: razer, color: white etc.
I need to take words between ":" and ",".
When I'm doing this in that way
Scanner sc = new Scanner(new File(path));
    String str = sc.nextLine();
    ArrayList<String> list = new ArrayList<String>();
    while (sc.hasNextLine()) {
        for (int i = 0; i < str.length(); i++) {
            list.add(str.substring(str.indexOf(":"), str.indexOf(",")));
        }
        System.out.println("test");
        sc.nextLine();
    }
I'm only taking ": intel". I don't know how to take more word from same line and them word from next line.
 
     
     
     
     
     
    