Java Scanner Usage createKeyboardScanner()

Here you can find the source of createKeyboardScanner()

Description

Creates and returns a Scanner that can be used to read from the keyboard.

License

Open Source License

Return

instance of for reading from keyboard

Declaration

public static Scanner createKeyboardScanner() 

Method Source Code

//package com.java2s;
/*==========================================================================*\
 |  $Id: IOHelper.java,v 1.3 2011/06/09 15:30:25 stedwar2 Exp $
 |*-------------------------------------------------------------------------*|
 |  Copyright (C) 2007-2010 Virginia Tech
 |
 |  This file is part of the Student-Library.
 |
 |  The Student-Library is free software; you can redistribute it and/or
 |  modify it under the terms of the GNU Lesser General Public License as
 |  published by the Free Software Foundation; either version 3 of the
 |  License, or (at your option) any later version.
 |
 |  The Student-Library is distributed in the hope that it will be useful,
 |  but WITHOUT ANY WARRANTY; without even the implied warranty of
 |  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 |  GNU Lesser General Public License for more details.
 |
 |  You should have received a copy of the GNU Lesser General Public License
 |  along with the Student-Library; if not, see <http://www.gnu.org/licenses/>.
\*==========================================================================*/

import java.util.Scanner;

public class Main {
    /**//w w w .ja  va2 s.c  o m
     * Creates and returns a {@link Scanner} that
     * can be used to read from the keyboard.  This is just a convenience
     * method for uniformity, since the Scanner class provides a constructor
     * that can take {@link System#in} as a parameter.
     * To enter text, you usually have to switch to some console in your
     * IDE.  Also, remember not to close the keyboard scanner.  The {@link
     * Scanner#nextLine()} method blocks until the user hits enter.
     *
     * @return instance of {@link Scanner} for reading from keyboard
     */
    public static Scanner createKeyboardScanner() {
        return new Scanner(System.in);
    }
}

Related

  1. computeSumTable(Scanner in, short n)
  2. confirm(String message)
  3. confirm(String message)
  4. confirmAction(String warning)
  5. countFileLines(Scanner fin)
  6. createScannerForString(String s)
  7. enterToContinue()
  8. equalsToIgnoreEndline(String expected, String actual)
  9. fromStringToQuery(String value)