简体   繁体   中英

Which Class used for writing characters rather than bytes?

在需要写字符而不是字节的情况下应该使用哪个类?

请看看java.io.Writer和子类。

An important thing to know about I/O in Java is that streams ( InputStream and OutputStream etc.) are used for reading and writing binary data (you read or write bytes exactly as they are in the file), and readers and writers ( Reader and Writer etc.) are for reading and writing characters.

Readers and writers are a layer on top of streams. A Reader interprets the bytes from an InputStream using a character encoding (such as UTF-8, ISO-8859-1, US-ASCII) to convert them into characters, and a Writer uses a character encoding to turn characters into bytes.

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