This is the way I learned it in class:
import java.util.*; // for the scanner
import java.io.*; // for the object
File f = new File("<filename>");
Scanner input = new Scanner(f);
input.useDelimiter(",|\"|\n"); // delimiters are commas, quotes, and newlines
input.nextInt(); //reads 1111 as an integer
input.next(); // reads the empty space (needed because " " wasn't declared as a delimiter)
input.next(); // reads in Top Secret Twenty One - Janet Evanovich as a String.
input.next(): // reads in the empty space
input.nextDouble(); // reads in 8.99 as a double
To change the default delimiters of Java (spaces, tabs, newlines), I used the following:
Scannervariable.useDelimiter(",|\"|\n");
This command uses commas, quotes, and newlines as delimiters, ignoring them and moving onto the next token. The | means "or." You can use the following Scanner methods depending on what you are trying to read in:
next(), nextInt(), nextDouble(), or nextLine()
You can look up the exact function of each method online.