OutputStream、InputStream是所有字节流的超类,所谓字节流就是一个字节一个字节的读取,类似于c中的二进制读取方法

java.io.OutputStream

Method

  void write(int b)

    Writes the specified byte to this output stream

  void write(byte[] b)    //   String 类的方法,  byte[] b = "中国".getBytes();   

    Writes b.length bytes from the specified byte array to this output stream.

  void write(byte[], int offset, int len)

    Writes len bytes from the specified byte array starting at offset off to this output stream.

        OutputStream out = new FileOutputStream("E:/a.txt");
        out.write(97);   // 写下二进制的97,文本编辑器读出二进制97,查询本机编码表,得出a
        
        byte[] b = {-43,-44};   //
        out.write(b);
        out.close();
View Code

相关文章: