scanner find in line character java code example
Example: find in line java
import java.util.*;
import java.util.regex.Pattern;
public class GFG1 {
public static void main(String[] argv)
throws Exception
{
try {
String s = "Geeksforgeeks has Scanner Class Methods";
System.out.println("Target String:\n" + s);
Scanner scanner = new Scanner(s);
System.out.println("\nAny 5 letter plus for : "
+ scanner.findInLine(
Pattern.compile(".....for")));
scanner.close();
}
catch (IllegalStateException e) {
System.out.println("Exception thrown : " + e);
}
}
}