<

Java IO Tutorial


Java io package provides for system input and output through data streams, serialization and the file system.


Streams


IO Streams are the core concept of Java IO. A stream is a conceptually endless flow of data. You can either read from a stream or write to a stream. A stream is connected to a data source or a data destination. Streams in Java IO can be either byte based or character based .


Input and Output - Source and Destination


The input of an application is often the output of another. Is an OutputStream a stream where output is written to, or output comes out from.After all, an InputStream outputs its data to the reading program, doesn't it is Personally, I found this a bit confusing back in the day when I first started out learning about Java IO.

Java's IO package is used to reading of raw data from a source and writing of raw data to a destination. The most typical sources and destinations of data are these.

  • Files

  • Pipes

  • Network Connections

  • In-memory Buffers (e.g. arrays)

  • System.in, System.out, System.error


  • Java IO Features


    Java IO contains many of the InputStream, OutputStream, Reader and Writer subclasses.All of these subclasses are addressing various different purposes. That is why there are so many different classes. The purposes addressed are summarized below:


  • File Access

  • Network Access

  • Internal Memory Buffer Access

  • Inter-Thread Communication (Pipes)

  • Buffering

  • Filtering

  • Parsing

  • Reading and Writing Text (Readers / Writers)

  • Reading and Writing Primitive Data (long, int etc.)

  • Reading and Writing Objects


  • Byte Based Input Output Character Based Input Output
    Basic Inputstream Outputstream Reader InputStreamReader Writer OutputStreamWriter
    Arrays ByteArrayInputStream ByteArrayOutputStream CharArrayReader CharArrayWriter
    Files FileInputStream RandomAccessFile FileOutputStream RandomAccessFile FileReader FileWriter
    Pipes PipedInputStream PipedInputStream PipedReader PipedWriter
    Buffering BufferedInputStream BufferedOutputStream BufferedReader BufferedWriter
    Filtering FilterInputStream FilterOutputStream FilterReader FilterWriter
    Parsing PushbackInputStream StreamTokenizer PushbackReader LineNumberReader
    Strings StringReader StringWriter
    Data DataInputStream DataOutputStream
    Data - Formatted PrintStream PrintWriter
    Objects ObjectInputStream ObjectOutputStream
    Utilities SequenceInputStream















    © copyright 2017-2022 Completedone pvt ltd.