Here you can find the source of getScannerContents(final Scanner scanner)
public static String getScannerContents(final Scanner scanner) throws IllegalArgumentException
//package com.java2s; //License from project: Open Source License import java.util.Scanner; public class Main { public static String getScannerContents(final Scanner scanner) throws IllegalArgumentException { String content;/*from ww w . ja va 2 s . co m*/ if (scanner.hasNext()) { // will be false if file size == 0 content = scanner.next(); } else { content = ""; } return content; } }