简体   繁体   中英

Java - Writing to a file as text or as binary

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.

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM