Java Scanner Read readFromScanner(Scanner scanner)

Here you can find the source of readFromScanner(Scanner scanner)

Description

read From Scanner

License

Open Source License

Declaration

private static String readFromScanner(Scanner scanner) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 *
 * Copyright (c) 2016 ecFeed AS.                                                
 * All rights reserved. This program and the accompanying materials              
 * are made available under the terms of the Eclipse Public License v1.0         
 * which accompanies this distribution, and is available at                      
 * http://www.eclipse.org/legal/epl-v10.html 
 *  //from w  w  w .  j  a v  a 2s  .co  m
 *******************************************************************************/

import java.util.Scanner;

public class Main {
    private final static String REGEX_BEGINNING_OF_TEXT = "\\A";

    private static String readFromScanner(Scanner scanner) {
        if (!scanner.hasNext()) {
            return new String();
        }
        // the entire content will be read 
        return scanner.useDelimiter(REGEX_BEGINNING_OF_TEXT).next();
    }
}

Related

  1. readFile(String project, boolean judge)
  2. readFileFully(InputStream stream)
  3. readFileToList(File file)
  4. readFileWithoutComments(File input)
  5. readFromReader(Scanner scanner)
  6. readInt(String prompt)
  7. readLine(String format, Object... args)
  8. readMatrix(Scanner in, int n)
  9. readPassword(String format, Object... args)