标签:system blog string csharp int har 内容 == ring
把输入的内容输出来:根据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 );
标签:system blog string csharp int har 内容 == ring
原文地址:http://www.cnblogs.com/achengmu/p/7209182.html