Scanner

import java.io.*;
import java.util.*;

public class ScannerDemo
{
  public static void main (String[] args) throws IOException
  {      
    String word;
    BufferedReader objReader = new BufferedReader (new InputStreamReader (System.in));
    
    System.out.print ("Please enter a line: ");
    String line = objReader.readLine (); // String input
    // example: "my dog is white"
    
    Scanner scannerObj = new Scanner(line); // convert String input into a scanner object
    // | my | dog | is | white |
    
    while (scannerObj.hasNext()) // True if another token is available to be read 
    {
      word = scannerobj.next(); // fetch one token at a time
    } 

  }
}


/*
Most common "next" input methods. 
s =  sc.next() Returns next "token", which is more or less a "word". 
s =  sc.nextLine() Returns an entire input line as a String. 
i =  sc.nextInt() Returns next integer value. 
d =  sc.nextDouble() Returns next double value. 
x =  sc.nextXYZ() Returns value of type XYZ (primitive value if possible), 
where XYZ is one of BigDecimal, BigInteger, Boolean, Byte, Float, or Short. 

Methods that test for availability of legal input for loops, optional 
elements, error checking. 

b =  sc.hasNext() True if another token is available to be read. 
b =  sc.hasNextLine() 
b =  sc.hasNextInt() True if another int is available to be read. 
b =  sc.hasNextDouble() True if another double is available to be read. 
b =  sc.hasNextXYZ() XYZ stands for one of the input types 
available above. 
*/

.............................................................................................................

To access Pig Latin Rules here...