Stream是面向byte的。
reader/writer是面向字符的。

解决方案 »

  1.   

    你好,能不能给一个键盘输入个人资料,包括姓名\身份证\住址\Email地址,并将其写入一个.txt文件的实例,让我更好的理解流.谢谢
      

  2.   

    OutputStream、InputStream 是抽象类,我们在实际开发中很少使用的,流是为了不依赖硬件而设计的,但我觉得流最好是理解为管道,只要适合就可以通过参数套接使用,当然每个流有不同的用途。
      

  3.   

    import java.io.*;
    import java.net.*;public class TestChar {
      public static void main(String[] args){
        BufferedReader in = null;
        FileWriter out = null;
        try {
          while(true){
            //建立緩存﹐并轉化為雙字節字符形式
            in = new BufferedReader(
              new InputStreamReader(System.in));
            out = new FileWriter("e:\\abbcc.txt",true);
            String line;
            line = in.readLine();
            //當輸入'bye'時退出
            if (line.equalsIgnoreCase("bye")) break;
            //加入換行符
            out.write(line+"\r\n");
            out.flush();
          }
        }
        catch (IOException ex) {
        }
        finally{
          try {
            //關閉流
            if (in != null) {
              in.close();
            }
            if (out != null) {
              out.close();
            }
          }
          catch (IOException ex1) {
          }
        }  }
    }
      

  4.   

    谢谢大家的帮助!
    要是给个键盘输入个人资料(姓名,QQ号,Email)然后写入文件的例子,剩下的30分全送了,呵呵,