Java在命令行界面中进行输入数据的技巧
发布时间:2021-11-24 15:36:03 所属栏目:PHP教程 来源:互联网
导读: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. *
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); } } ![]() (编辑:应用网_丽江站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |