斑蝥虫专卖店:怎样使用java中的各种流

来源:百度文库 编辑:神马品牌网 时间:2024/04/30 00:44:39
请JAVA高手指教!!!

1. stream代表的是任何有能力产出数据的数据源,或是任何有能力接收数据的接收源。在Java的IO中,所有的stream(包括Input和Out stream)都包括两种类型:以字节为导向的stream和以Unicode字符为导向的stream
2. 用于封装以字节为导向的InputStream和用于封装以字符为导向的InputStream
3.用于封装以字节为导向的OutputStream和用于封装以字符为导向的OutputStream
示范:
1、BufferedReader in = new BufferedReader(new FileReader("F:\\nepalon\\TestIO.java"));
2、BufferedReader stdin = new BufferedReader(
new InputStreamReader(System.in));
3、StringReader in2 = new StringReader(s2);
int c;
while((c = in2.read()) != -1)
System.out.println((char)c);
4、try{
DataInputStream in3 =
new DataInputStream(
new ByteArrayInputStream(s2.getBytes()));
while(true)
System.out.println((char)in3.readByte());
}
catch(EOFException e){
System.out.println("End of stream");
}//内存读取
http://hunulei.blogbus.com/logs/2005/07/1296309.html这里有详细的解释!