If theres not much input, you can just use a Scanner (sc), and use sc.nextInt(), int.
If theres a lot of input, thats far too slow, so I use a BufferedReader (br), and then split() the string. For example,
String[] inputParts = br.readLine().trim().split("\\s++");
where that regular expression means 'one or more whitespace'.