Scanner: findInLine(String str) : Scanner : java.util : Java by API examples (example source code) Organized by topic

Java by API
C++
PHP
Java by API Home »  java.util   » [  Scanner  ]   
 



Scanner: findInLine(String str)

/**
 *Output:
28
 */

import java.util.Scanner;

public class MainClass {
  public static void main(String args[]) {
    String instr = "Name: Joe Age: 28 ID: 77";

    Scanner conin = new Scanner(instr);

    conin.findInLine("Age:")// find Age

    if (conin.hasNext())
      System.out.println(conin.next());
    else
      System.out.println("Error!");

  }
}

           
       
Related examples in the same category
1.  new Scanner(FileReader file)
2.  new Scanner(InputStream source)
3.  new Scanner(String instr)
4.  new Scanner(Readable source)
5.  Scanner: hasNext()
6.  Scanner: hasNextBoolean()
7.  Scanner: hasNextDouble()
8.  Scanner: hasNextInt()
9.  Scanner: next()
10.  Scanner: nextBoolean()
11.  Scanner: nextDouble()
12.  Scanner: nextInt()
13.  Scanner: useDelimiter(String pattern)
























Home| Contact Us
Copyright 2003 - 04 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.