Here you can find the source of readLine(String prompt, boolean force)
public static String readLine(String prompt, boolean force)
//package com.java2s; //License from project: Open Source License import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static String readLine(String prompt, boolean force) { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String s = null;//w ww . ja va 2 s . c o m try { System.out.print(prompt + ":"); System.out.flush(); s = br.readLine(); while (force && ((s == null) || (s.trim().length() == 0))) { System.out.print(prompt + ":"); s = br.readLine(); } } catch (IOException ioe) { System.out.println("IO error trying to read your name!"); System.exit(1); } return s; } public static String readLine(String prompt) { return readLine(prompt, false); } }