Here you can find the source of readFromScanner(Scanner scanner)
private static String readFromScanner(Scanner scanner)
//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(); } }