Java Scanner Usage createScannerForString(String s)

Here you can find the source of createScannerForString(String s)

Description

Creates a Scanner that can be used to read directly from a given text string.

License

Open Source License

Parameter

Parameter Description
s the string to read from

Return

instance of for reading from the given string

Declaration

public static Scanner createScannerForString(String s) 

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 {
    /**/*from w  w w .  ja va2s. c om*/
     * Creates a {@link Scanner} that can be used to
     * read directly from a given text string.  This is just a convenience
     * method for uniformity, since the Scanner class provides a constructor
     * that can take a String as a parameter.
     *
     * @param s  the string to read from
     * @return   instance of {@link Scanner} for reading from
     *           the given string
     */
    public static Scanner createScannerForString(String s) {
        return new Scanner(s);
    }
}

Related

  1. confirm(String message)
  2. confirm(String message)
  3. confirmAction(String warning)
  4. countFileLines(Scanner fin)
  5. createKeyboardScanner()
  6. enterToContinue()
  7. equalsToIgnoreEndline(String expected, String actual)
  8. fromStringToQuery(String value)
  9. getBoolean()