overview

Origin

IO operations include reading and writing, and apply to both network operations and file operations. IO operations in Java are a relatively complex process, so we need to choose different InputStream and OutputStream implementations to complete these operations when facing different scenarios. If you want to read and write byte streams, you also need various Reader and Writer implementations. These numerous implementation classes provide us with more flexibility on the one hand, but also increase complexity on the other hand.

Packaging

The packaging of the io package mainly focuses on the packaging of streams and file reading and writing, mainly in the form of utility classes. These include:

  • IoUtil: A utility class for stream operations
  • FileUtil: A utility class for file reading and writing and operations
  • FileTypeUtil: A utility class for file type identification
  • WatchMonitor: A directory and file monitoring tool that encapsulates the WatchService in JDK 1.7
  • ClassPathResource: An encapsulation of ClassPath resources
  • FileReader: An encapsulation of file reading
  • FileWriter: An encapsulation of file writing

Stream Extensions

In addition to encapsulating the reading and writing of JDK, there are also extensions for specific environments and files.

These include:

  • BOMInputStream: Reads streams containing BOM headers
  • FastByteArrayOutputStream: An OutputStream based on the FastByteBuffer that automatically expands the buffer as data grows (from blade)
  • FastByteBuffer: A fast buffer that stores data in a buffer collection, replacing the previous single array (from blade)