Which class should 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With