JAVA在命令行界面中进行输入数据的方法
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); } }
posted on 2012-01-02 18:38 java课程设计例子 阅读(251) 评论(0) 编辑 收藏 举报