keyboard
, files
or network
and then
produces data (output) to different destinations such as
console
, files
, printers
, network
or other devices.
images
, audio
, video
and other non-text files.
.txt
, .java
, .xml
and other Unicode-based files.
System
class.
System.in
BufferedInputStream
by default).
int data = System.in.read(); // reads a single byte
System.out
OutputStream
).
System.out.println("Hello World");
System.err
System.out
, but meant for errors).
System.err.println("This is an error message");
java.io
Package
java.io
package provides stream-based I/O for reading and writing data (bytes or characters) sequentially.
InputStream
, OutputStream
(read/write bytes)
Reader
, Writer
(read/write characters)
FileInputStream
, FileOutputStream
β Read/write bytes from/to filesFileReader
, FileWriter
β Read/write text filesBufferedInputStream
, BufferedOutputStream
, BufferedReader
, BufferedWriter
β Buffered streams for efficiencyDataInputStream
, DataOutputStream
β Read/write primitive data typesObjectInputStream
, ObjectOutputStream
β Read/write objects (serialization)PrintWriter
β Write formatted textjava.nio
Package
java.nio
package provides buffer-oriented, non-blocking I/O for high-performance file handling.
FileChannel
β Read/write files using channelsByteBuffer
, CharBuffer
β Buffers for data storagePath
, Paths
, Files
β Modern file operations (create, delete, copy, move)StandardOpenOption
β Specify options when opening filesCharset
β Encoding/decoding for character datakeyboard
, file
, or network
.
console
, file
, or printer
.
images
, audio
, and video
.
Your feedback helps us grow! If there's anything we can fix or improve, please let us know.
Weβre here to make our tutorials better based on your thoughts and suggestions.