Java.io writers and readers - how do you know what to use?

There are quite a few classes that extend java.io.Writer and java.io.Reader.

Are there circumstances in which you should use one over the other? What is the general usefulness of each of them (why are there so many)?

Do they have distinctive performance attributes? They all just write / read from the stream - right?

Does anyone know of a record that will give me examples of where you will use one over the other.

The same question applies to valid files. There seem to be several ways to open a file stream for reading / writing.

Thank.

+3
source share
2 answers

The name of the reader says a lot about the precedent.

FileReader/StringReader/CharArrayReader/InputStreamReader Files, Strings, CharArrays InputStream. .

LineNumberReader/PushbackReader/BufferedReader "Standalone", -Reader. new BufferedReader( new FileReader(file) );

Reader , , , . BufferedReader LineNumberReader .

PipedReader / / PipedWriter....

... Reader Writer, Decorator.

+4

, . , , " ". , , , FileReader. , .

, , Writer.

+1

All Articles