把输入的内容输出来:根据system.in的内容System.out.println输出出来
//限制读取的字符长度 InputStream ips = System.in; byte b[] = new byte[20]; System.out.println("请输入:"); int len = ips.read(b); System.out.println( new String(b, 0, len) ); //不限制读取的输入的字符长度 InputStream ipt = System.in; System.out.println("请输入:"); int temp = 0; StringBuffer buff = new StringBuffer(); while( (temp = ipt.read()) !=-1 ) { char c = (char)temp; //判断是否打回车键 if(c == ‘\n‘) { break; } buff.append(c); } System.out.println("输入的字符是:" + buff );
时间: 2024-10-06 19:38:33