[英]Which Class used for writing characters rather than bytes?
在需要写字符而不是字节的情况下应该使用哪个类?
请看看java.io.Writer
和子类。
PrintWriter will be useful PrintWriter将很有用
http://download.oracle.com/javase/1.4.2/docs/api/java/io/PrintWriter.html 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. 一个重要的事情了解的I / Java中0为流 ( InputStream
和OutputStream
等)用于读取和写入二进制数据(你读或写,正是因为他们是文件中的字节),以及读者和作家 ( Reader
和Writer
等)用于读取和写入字符。
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. Reader
器使用字符编码(例如UTF-8,ISO-8859-1,US-ASCII)解释InputStream
的字节,以将其转换为字符,而Writer
使用字符编码将字符转换为字节。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.