Get The Standard Input In Java
In this sample java program you will see how to get standard input enter by the user and print its value on the console:
- Sample java program:
package com.javahonk; import java.util.Scanner; public class GetStandardInput { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.println("Enter something on cosole-->"); while (scanner.hasNext()) { String string = (String) scanner.next(); System.out.print(string+"\\s"); } scanner.close(); } }
- Output:
For more information about I/O form command line please read oracle documentation here