package com.myapp.test;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
public class ScannerTest {
public static void main(String[] args) {
String firstName;
InputStreamReader inStream = new InputStreamReader(System.in);
BufferedReader inBuf = new BufferedReader(inStream);
System.out.print("Pleaseenter your first name => ");
try {
firstName = inBuf.readLine();
System.out.print("first name => " + firstName);
}
// end of first try block
catch (IOException e) {
System.out.println("Problemreading first name");
return;
} // end catch block
// Scanner class test
String lastName;
System.out.print("Please enter your last name => ");
Scanner fromkeyboard = new Scanner(System.in);
lastName = fromkeyboard.next();
System.out.print("last name => " + lastName);
}
}
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
public class ScannerTest {
public static void main(String[] args) {
String firstName;
InputStreamReader inStream = new InputStreamReader(System.in);
BufferedReader inBuf = new BufferedReader(inStream);
System.out.print("Pleaseenter your first name => ");
try {
firstName = inBuf.readLine();
System.out.print("first name => " + firstName);
}
// end of first try block
catch (IOException e) {
System.out.println("Problemreading first name");
return;
} // end catch block
// Scanner class test
String lastName;
System.out.print("Please enter your last name => ");
Scanner fromkeyboard = new Scanner(System.in);
lastName = fromkeyboard.next();
System.out.print("last name => " + lastName);
}
}