// **************************************************************** // ParseInts.java // // Reads a line of text and prints the integers in the line. // // **************************************************************** import java.io.*; import java.util.*; public class ParseInts { public static void main(String[] args) throws IOException { BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.in)); int val, sum=0; System.out.println("Enter a line of text"); StringTokenizer toks = new StringTokenizer(keyboard.readLine()); while (toks.hasMoreTokens()) { val = Integer.parseInt(toks.nextToken()); sum += val; } System.out.println("The sum of the integers on this line is " + sum); } }