Java Utililty Methods Console Read

List of utility methods to do Console Read

Description

The list of methods to do Console Read are organized into topic(s).

Method

ArrayListgetCommandArgs(String command)
get Command Args
ArrayList<String> list = new ArrayList<String>();
Scanner scanner = new Scanner(command);
scanner.useDelimiter(" ");
while (scanner.hasNext()) {
    list.add(scanner.next());
return list;
StringgetInScanner()
Membaca masukan data dari keyboard (pendekatan Scanner) Pembatas adalah carriage return (enter)
String s = "";
Scanner input = new Scanner(System.in).useDelimiter("\r");
s += input.next();
return s;
StringgetUserInput()
Read from console user string
Scanner scanner = new Scanner(System.in);
String userInput = scanner.nextLine();
return userInput;
StringgetUserInput()
get User Input
Scanner in = new Scanner(System.in);
String response = in.nextLine();
in.close();
return response;
StringgetUserInput(String text, int indentLevel)
get User Input
indent(indentLevel);
System.out.printf("%s: ", text);
Scanner scanner = new Scanner(System.in);
return scanner.nextLine();
StringgetUserInput(String whatever)
Obtain user input from command line
System.out.print("Enter " + whatever + " :");
@SuppressWarnings("resource")
Scanner scanner = new Scanner(System.in);
return scanner.nextLine();
intinputInt()
input Int
Scanner sc = new Scanner(System.in);
return sc.nextInt();
StringinputString()
input String
Scanner sc = new Scanner(System.in);
String string = sc.next();
if (isNumeric(string))
    throw new InputMismatchException();
return string;
StringreadLine(Console console)
read Line
console.printf("> ");
return console.readLine().trim();