We would like to know how to scan a String by value type.
import java.util.Scanner; //from www . j av a2 s. c o m public class MainClass { public static void main(String args[]) { String instr = "10 99.88 scanning is easy."; Scanner conin = new Scanner(instr); while (conin.hasNext()) { if (conin.hasNextDouble()) { System.out.println(conin.nextDouble()); } } } }
The code above generates the following result.