Code example for Scanner

Methods: hasNextLineuseDelimiter

0
	// return rest of input as string 
	/** 
	 * Read and return the remainder of the input as a string. 
	 */ 
	public String readAll() {
		if (!scanner.hasNextLine()) {
			return null; 
		} 
 
		// reference: 
		// http://weblogs.java.net/blog/pat/archive/2004/10/stupid_scanner_1.html 
		return scanner.useDelimiter("\\A").next();
	} 
 
	/** 
	 * Return the next string from the input stream. 
	 */ 
	public String readString() {
		return scanner.next();
	} 
Contextual code suggestions in your IDE  Get Codota for Java