Java I/O streams; what are the differences?

后端 未结 9 1274
死守一世寂寞
死守一世寂寞 2020-12-12 18:44

java.io has many different I/O streams, (FileInputStream, FileOutputStream, FileReader, FileWriter, BufferedStreams... etc.) and I am confused in determining th

9条回答
  •  余生分开走
    2020-12-12 19:01

    When learning Java I made this mental scheme about java.io:

    Streams

    • byte oriented stream (8 bit)
    • good for binary data such as a Java .class file
    • good for "machine-oriented" data

    Readers/Writers

    • char (utf-16) oriented stream (16 bit)
    • good for text such as a Java source
    • good for "human-oriented" data

    Buffered

    • always useful unless proven otherwise

提交回复
热议问题