Java: Difference between PrintStream and PrintWriter

后端 未结 6 1022
天涯浪人
天涯浪人 2020-11-28 18:47

What is the difference between PrintStream and PrintWriter? They have many methods in common due to which I often mix these two classes up. Moreove

6条回答
  •  余生分开走
    2020-11-28 19:31

    Writers like PrintWriter are for text output, streams are for binary output. The writers handle character set stuff for you. Streams don't because it's assumed that you don't want that sort of conversion, which would mess up your binary data, and would be using a writer if you did.

提交回复
热议问题