Here you can find the source of inputString()
protected final static String inputString()
//package com.java2s; //License from project: BEER-WARE LICENSE import java.util.InputMismatchException; import java.util.Scanner; public class Main { protected final static String inputString() { Scanner sc = new Scanner(System.in); String string = sc.next(); if (isNumeric(string)) throw new InputMismatchException(); return string; }//from www . ja v a2 s.c om protected final static boolean isNumeric(String string) { return string.matches("[-+]?\\d*\\.?\\d+"); } }