There are too many java.io classes, for some of them i really dont understand when we need them, for example:
ByteArrayInputStream, ByteArrayOutputStream
SequenceInputStream,
PushbackInputStream, PushbackReader
StringReader...
I mean some real-life usages
Can someone please explain...
I would say that your question is too wide.
However it is possible to give a very basic overview of java.io
package. It contains interfaces and classes for data input and output operations, such as reading bytes from file. There are only few basic interfaces / classes:
DataInput
/ ObjectInput
- readig Java primitives and objectsDataOutput
/ ObjectOutput
- writing Java primitives and objectsInputStream
- reading individual bytesOutputStream
- writing individial bytesReader
- reading character dataWriter
- writing character dataThere are other useful interfaces (like Closeable
), but these are less significant.
It is best if you read the JavaDoc of these classes. Some examples:
FileOutputStream
to write something into a file.OutputStreamWriter
.byte[]
and want to read from it just like from InputStream
? Use ByteArrayInputStream
.PushbackReader
.String
and want to read from it just like from Reader
? Use StringReader
.So if you need some specific stream/reader/writer, check java.io
package, search the internet and ask a question on SO if needed.
Of course then there is java.nio
package, which you should know about. But that is for a different topic.