Java.Streams.In which packages are the classes of input/output streams located?

✅ 1. java.io — Traditional I/O (Streams API)

This is the main package that contains most of the classic input/output stream classes.

🔹 Byte Streams

TypeClass Names
InputInputStream, FileInputStream, BufferedInputStream, DataInputStream, ByteArrayInputStream, ObjectInputStream, PipedInputStream
OutputOutputStream, FileOutputStream, BufferedOutputStream, DataOutputStream, ByteArrayOutputStream, ObjectOutputStream, PipedOutputStream

🔹 Character Streams

TypeClass Names
ReaderReader, FileReader, BufferedReader, CharArrayReader, StringReader, InputStreamReader
WriterWriter, FileWriter, BufferedWriter, CharArrayWriter, StringWriter, OutputStreamWriter

✅ 2. java.nio and java.nio.file — New I/O (NIO & NIO.2)

Introduced in Java 1.4 and extended in Java 7 (NIO.2), these packages contain:

  • Channel classes (e.g., FileChannel, SocketChannel)
  • Buffer classes (e.g., ByteBuffer, CharBuffer)
  • Path, Files, FileSystems (modern file operations)
  • WatchService (directory monitoring)
  • Asynchronous* classes for non-blocking I/O

🧠 Summary Table

PackagePurpose
java.ioClassic I/O streams (blocking)
java.nioBuffers, channels, selectors
java.nio.fileModern file system API (Path, Files, etc.)
java.nio.channelsChannels like FileChannel, SocketChannel
This entry was posted in Без рубрики. Bookmark the permalink.

Leave a Reply

Your email address will not be published.