Java IO Package Tutorial

Java.io package provides classes for system input and output through data streams, serialization, and the file system. This reference will take you through simple and practical methods available in a java.io package.

This tutorial is prepared for the beginners to help them understand the basic functionality related to all the methods available in Java.io package.

Let's discuss a list of important commonly used Java I/O classes under java.lang package. We explained all the methods with lots of examples from each class. Our suggestion is to do lots of hands experience using this tutorial.

Click on each class will navigate to their respective page.

>> java.io FileOutputStream Class

In this article, we will explore important methods of this class with examples. FileOutputStream creates an OutputStream that you can use to write bytes to a file. It implements the AutoCloseable, Closeable, and Flushable interfaces.

>> java.io FileInputStream Class

In this article, we will discuss how the FileInputStream class creates an InputStream that you can use to read bytes from a file. It is used for reading byte-oriented data (streams of raw bytes) such as image data, audio, video etc.

>> java.io ByteArrayOutputStream Class

In this article, we will explore ByteArrayOutputStream class APIs. ByteArrayOutputStream is an implementation of an output stream that uses a byte array as the destination.

>> java.io ByteArrayInputStream Class

In this article, we will explore ByteArrayInputStream class APIs. ByteArrayInputStream is an implementation of an input stream that uses a byte array as the source.

>> java.io BufferedWriter Class

In this article, we will explore BufferedWriter class APIs. BufferedWriter class writes text to a character-output stream, buffering characters so as to provide for the efficient writing of single characters, arrays, and strings.

>> java.io BufferedReader Class

Reads text from a character-input stream, buffering characters so as to provide for the efficient reading of characters, arrays, and lines.

>> java.io BufferedOutputStream Class

Java BufferedOutputStream class is used for buffering an output stream. It internally uses a buffer to store data. It adds more efficiency than to write data directly into a stream. So, it makes the performance fast.

>> java.io BufferedInputStream Class

Java BufferedInputStream class is used to read information from the stream. It internally uses a buffer mechanism to make the performance fast.

>> java.io FileWriter Class

FileWriter creates a Writer that you can use to write to a file. FileWriter is convenience class for writing character files. The constructors of this class assume that the default character encoding and the default byte-buffer size are acceptable. To specify these values yourself, construct an OutputStreamWriter on a FileOutputStream.

>> java.io FileReader Class

The FileReader class creates a Reader that you can use to read the contents of a file. FileReader is meant for reading streams of characters. For reading streams of raw bytes, consider using a FileInputStream.

>> java.io DataOutStream Class

Java DataOutputStream class allows an application to write primitive Java data types to the output stream in a machine-independent way.

>> java.io DataInputStream Class

Java DataInputStream class allows an application to read primitive data from the input stream in a machine-independent way. Java application generally uses the data output stream to write data that can later be read by a data input stream.

>> java.io ObjectOutputStream Class

An ObjectOutputStream writes primitive data types and graphs of Java objects to an OutputStream.

>> java.io ObjectInputStream Class

ObjectInputStream deserializes primitive data and objects previously written using an ObjectOutputStream.

Reference

java.io Package from Javadoc 8

Comments

  1. This is an awesome post. Really very informative and creative contents. This concept is a good way to enhance knowledge. I like it and help me to development very well. Thank you for this brief explanation and very nice information. Well, got good knowledge.
    WordPress website development Chennai

    ReplyDelete

Post a Comment