import java.util.*;
public class ScannerTest {
public static void scanTest(){
Scanner scanner=new Scanner(System.in);
System.out.println("Please enter a integer number : ");
if(scanner.hasNextInt()){
int myInt=scanner.nextInt();
System.out.println("You entered integer number : "+myInt);
}else{
System.out.println("That's not an integer : "+scanner.next());
}
System.out.println("Please enter a real number : ");
Locale locale=new Locale("tr","TR");
scanner.useLocale(locale);
scanner.useLocale(Locale.US);
if(scanner.hasNextDouble()){
int myDouble=scanner.nextInt();
System.out.println("You entered real number : "+myDouble);
}
}
public static void findTest(){
Scanner scanner=new Scanner(System.in);
System.out.println("Please enter a string : ");
String found=scanner.findWithinHorizon("\\bJava.*",15);
System.out.println("Found : "+found);
}
public static void main(String[] args) {
findTest();
}
}
Dosyayı İndir