I think you're over-thinking things -- you don't need to use useDelimiter
since Java's Scanner object automatically will split via whitespace.
Scanner scan = new Scanner(new File("myFile"));
ArrayList<Task> output = new ArrayList<Task>();
while (scan.hasNext()) {
String s = scan.next();
int num1 = scan.nextInt();
int num2 = scan.nextInt();
output.add(new Task(s, num1, num2));
}
Note that the above code will fail if the input does not exactly match the pattern of string-int-int -- the nextInt
method in a Scanner will fail if the next token cannot be interpreted as an int, and the code will throw an exception if the number of tokens in the input is not a multiple of three.