/****************************************************************************** * This program computes the sum of a list of integer values on STDIN. * * Copyright © 2016 Richard Lesh. All rights reserved. *****************************************************************************/ import org.pureprogrammer.Utils; public class TotalFilterInt { public static void main(String[] args) { String line; int d; int total = 0; while ((line = Utils.getline()) != null) { line = Utils.trim(line); try { d = Integer.parseInt(line); total += d; } catch (Exception ex) { if (Utils.cpLength(line) > 0) { System.out.println(Utils.join("", "Can't parse input: ", line)); } } } System.out.println(Utils.format("{0:d}", total)); } }