First, Scanner#next()
only returns the next token. With a default configuration, tokens are separated by whitespace characters. So the first call to
String nameIn = names.next();
would return
Nathan
which, when split, only returns an array with length 1.
Use Scanner#nextLine()
to retrieve all input until a new line character is found.
Second, it doesn't seem like your tokens are separated by tab characters, \t
. Use
String delims = ("\\s+");
to split by one or more whitespace characters.