I have a text file that contains value like this:
name1, value1, number 1,
name2, value2, number 2,
I search in this file with the first value (let say name2) and I want to put in the list value2 and number2. How can I do this? For the first value I did it but I don't know how to do to store all the date from that line..
public static List<String> findLocalityValues(String path, String word) throws FileNotFoundException {
Scanner scanner = new Scanner(new File(path)).useDelimiter(word + ",");
List<String> list = new ArrayList<String>();
while (scanner.hasNext()) {
String found = scanner.next();
list.add(found.substring(0, found.indexOf(',')));
}
return list;
}