How to input your personal data from the default command interface.
It used the System.in.read, contrast to the System.out.print.
- package com.han;
-
- import java.io.*;
- /**
- * How to input your personal data from the default command interface.
- * <p>
- * It used the System.in.read, contrast to the System.out.print.
- * @author han
- *
- */
- public class InputSystem{
- public static void main(String args[]){
- byte[] buffer=new byte[512];
- try {
- System.out.print("請你輸入: ");
- System.in.read(buffer);//input your data, and ends with a "Return" key.
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- String str=new String(buffer);
-
- System.out.println("what you input is : "+str);
- }
- }