This program is from K&B page-484 ,When I run it:-
it produces this:-
java SearchTest "\d+"
input: dsfs12fsf2f1
found 12
found 2
found 1
found null
Someone tell me at last why it found null !! import java.util.regex.*;
import java.util.*;
class SearchTest
{
public static void main(
String[] args)
{
System.out.print("input:");
System.out.flush();
try
{
Scanner s = new Scanner(System.in);
String token;
do
{
token = s.findInLine(args[0]);
System.out.println("found "+token);
}
while(token!=null);
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
}