Hi Ignacio

You are perfectly right, Readers are better adapted to character based operations than InputStreams.

But the purpose of the exercise is (I think) to introduce you to the "Matroshka" (Russian embedded dolls) architecture of the Streams - you see one doll (an InputStream) but it may be a filter that hides another doll that is a filter that hides another doll and so on (FilterInputStream based on a FilterInputStream based on a BufferedInputStream based on a FileInputStream - for e.g.).

Input/Output streams are important because they allow you to access any byte in any file, including binary files such as PDF files, database files or code-page encoded text files. The minimum thing to know is how to access any file.

UTF-8 encoded text files can be read using InputStreams, but they don't offer particular facilities to do that. The difficulty consist of the fact that characters may use one or two or more bytes and, to do it properly, you should be able to understand UTF-8 encoding. As you said, Readers are better adapted to this task, as they return Unicode characters based on the encoding of the input file. Readers use a "Matroshka"-like architecture too.

But, as I said, the purpose of the exercise is to learn you to do at least the basic "any file" operations. Considering that any byte is a character (that will not always work, but will work if the file contains only ASCII characters - it is enough for the exercise), you can do your homework (unless you want to raise to upper cases things like "T,a(râna(".

If you wish, I think it would be a nice exercise to do the homework as described, then to do it again using Readers!

Hope it helps
Mihai

(PS: Of course, the things said here apply to OutputStreams versus Writers, like in a mirror).


ignacio giagante a écrit :
Hi, I'm doing the exercise of the unit I/O Stream and I think that something in the homework is wrong.

    *class to convert the characters read to upper case *


Can I use the class FilterReader instead of FilterInputStream? or It is necesary to use the class you proposed in the exercise? Because, I'n going to work with characters and not with byte, which are translate to ints.
Regards,

Ignacio
--
Sarang Singh
--
To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/javaprogrammingwithpassion?hl=en

--
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/javaprogrammingwithpassion?hl=en

Reply via email to