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 data
There are other useful interfaces (like Closeable
), but these are less significant.
It is best if you read the JavaDoc of these classes. Some examples:
- It is pretty obvious that you would use
FileOutputStream
to write something into a file. - Character data is represented by bytes (defined by character encoding), so you can wrap any output stream using
OutputStreamWriter
. - You have
byte[]
and want to read from it just like fromInputStream
? UseByteArrayInputStream
. - You want to be able to return read bytes back to the reader (usually only a single pass-through is supported)? Wrap your reader with
PushbackReader
. - You have some
String
and want to read from it just like fromReader
? UseStringReader
. - ...
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.