So I have a String that was given to me. I have eliminated all non integer characters, except for whitespace. Each line the amount of integer varies, some lines I will have one, sometimes I have two or even three. I now need to read in each integer and add them to an array list accordingly. Currently this is what I have:
while(fileScanner.hasNextLine()){
fileScanner.nextLine();
line=lineReplacer.nextLine();
String line2=line.replaceAll("[a-z]","").replaceAll("[A-Z]","").replaceAll(": ","").replaceAll(" ","").replaceAll(", ", " ");
specs.add(Integer.parseInt(line2));
}
I am stuck on how to add in each int, without getting an error, without knowing how many ints are the line I currently have.
Edit: Expected values would be things such as, 2 2 2, or 12 14 11, or just 10, or 29 30. The ints must stay separated because they need to be added to an array. The only limitation on input is that it isn't more than three ints.
Scanner.nextInt()?