// // SystemInputReader.java // // // Created by Gene Davis on Sat Aug 18 2001. // Copyright (c) 2001 Gene Davis. I hereby release this code to the public domain. // It is now in every sense of the word Freeware. Future versions can be found // at http://www.genedavis.com/library/ // // version 1.0 package com.genedavis.io; import java.io.*; public class SystemInputReader { BufferedReader keyboardInput = null; String newLine = null; /** * Creates new SystemInputReader */ public SystemInputReader() { keyboardInput = new BufferedReader(new InputStreamReader(System.in)); } /** * This retrieves text one line at a time from the keyboard and returns a line at a time as a String. * This will block until the user types and enters a line with or without text. I usually tack a String.trim() * on to the end of the return before using it. * * @param String representing a new line of text inputed from the keyboard. */ public String nextLine() { try { newLine = keyboardInput.readLine(); } catch (Exception e){ e.printStackTrace(); } return newLine; } }