FileDocCategorySizeDatePackage
ReadStdinInt15.javaAPI DocExample550Sun Mar 07 10:31:58 GMT 2004None

ReadStdinInt15

public class ReadStdinInt15 extends Object
Read an int from Standard Input, using 1.5
author
Ian F. Darwin, http://www.darwinsys.com/
version
$Id: ReadStdinInt15.java,v 1.2 2004/03/07 16:31:58 ian Exp $

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] ap)

		int val;
		try {
			Scanner sc = Scanner.create(System.in);      // Requires J2SE 1.5
			val = sc.nextInt();
		} catch (NumberFormatException ex) {
			System.err.println("Not a valid number: " + ex);
			return;
		}
		System.out.println("I read this number: " + val);