Java - Writing to a file as text or as binary

时间:2015-09-14 15:53:46

标签: java stream buffered

I have a question about using streams with files. I know that if I need to do my own file type then the best option is to write/read in binary using for example BufferedInput/Ouput streams. I have always been considering the best performance in my program so now I am curious about writing/reading strings. I have been using Writer and Reader classes with BufferedReader/Writer streams. I have been asking myself If it worths to write/read strings in binary format. I think there might be some performance boost but is this boost noteworthy?

Thank you for your answers.

1 个答案:

答案 0 :(得分:0)

If you are reading/writings lines of characters, continue to use the Buffered reader/writer.

Quoting the documentation:

Class BufferedReader... Reads text from a character-input stream, buffering characters so as to provide for the efficient reading of characters, arrays, and lines.