From the course: Java SE 21 Developer (1Z0-830) Cert Prep

Unlock this course with a free trial

Join today to access over 25,900 courses taught by industry experts.

BufferedReader, PrintWriter, Scanner and Charset conversions

BufferedReader, PrintWriter, Scanner and Charset conversions - Java Tutorial

From the course: Java SE 21 Developer (1Z0-830) Cert Prep

BufferedReader, PrintWriter, Scanner and Charset conversions

- Now let's look at the buffered reader, print writer, scanner and chart sets. The classes input stream reader and output stream writer perform conversion between eight bid encodings and 16 bit Unicode. What we'll do is instantiate the objects with an argument that is the stream that will carry the eight bit data. Optionally, we can specify the eight bit character set using its textual name, a Charset, or a Charset decoder. Alternatively, we can just accept the platform's default in coding. So these four reader objects created here are all equivalent. Notice we have initialized a charset object and in this case we've simply asked the platform for its default charset. We have then also extracted the textural name of that charset into a string CS name and we've asked Cs to create a Charset decoder for us. Then in each case we create an input stream reader just with different arguments. One, we simply say system. in and…

Contents