Re: I/O from the Command Line in Java
I have given you an example that demonstrates how to read command line input from a Java program using the Scanner class :
Code:
import java.util.Scanner;
public class ScannerDemo
{
public static void main (String[] args)
{
System.out.print("Enter your Qualification: ");
Scanner scanner = new Scanner(System.in);
String username = scanner.nextLine();
if (username.trim().equals(""))
{
System.out.println("That's not valid qualification");
}
else
{
System.out.println("Thanks for the qualification, " + username);
}
}
}
I do to dead flowers what people at morgues do to dead people. Suck all the moisture out, dip them in plastic, paint them up pretty and put them in a nice frame.
Bookmarks