Scanner: findWithinHorizon(String pattern, int horizon) : Scanner « java.util « Java by API






Scanner: findWithinHorizon(String pattern, int horizon)

 
import java.util.Scanner;

public class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner("Name: Tom Age: 28 ID: 77");

    sc.findWithinHorizon("ID:",100);

    if (sc.hasNext())
      System.out.println(sc.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: findInLine(String str)
6.Scanner: hasNext()
7.Scanner: hasNextBoolean()
8.Scanner: hasNextDouble()
9.Scanner: hasNextInt()
10.Scanner: hasNextLine()
11.Scanner: next()
12.Scanner: nextBoolean()
13.Scanner: nextDouble()
14.Scanner: nextInt()
15.Scanner: nextLine()
16.Scanner: useDelimiter(String pattern)