标签:public input 一个 显示 建立 ati buffered 字符 代码
import java.io.*;
public class test {
static String loadStream(InputStream in) throws IOException {
StringBuffer buffer = new StringBuffer();
int count= 1,i=6;
byte[] buf = new byte[count];//缓冲区
while(i-->0) {
in.read(buf,0,count);
System.out.println(new String(buf));//按字节显示一下
buffer.append(new String(buf)); //连接一个字符串
}
return new String(buffer);
}
public static void main(String[] args) throws IOException {
InputStream in = new BufferedInputStream(System.in);//in必须要初始化一个对象,不能为null
String test=loadStream(in);
System.out.println("msg=: "+test);
}
}
标签:public input 一个 显示 建立 ati buffered 字符 代码
原文地址:https://www.cnblogs.com/He-Fan/p/12112873.html