您的位置:首页 > 编程语言 > Java开发

JAVA在命令行界面中进行输入数据的方法

2012-01-02 18:38 369 查看
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);
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: