开发者

Which Class used for writing characters rather than bytes?

Which class shou开发者_StackOverflow社区ld be used in situations that require writing characters rather than bytes?


Please take a look at java.io.Writer and subclasses.


PrintWriter will be useful

http://download.oracle.com/javase/1.4.2/docs/api/java/io/PrintWriter.html


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜