Java Input/Output

Java IO is an API that comes with Java which is targeted at reading and writing data (input and output). Most applications need to process some input and produce some output based on that input. For instance, read data from a file or over network, and write to a file or write a response back over the network.

The Java IO API is located in the Java IO package (java.io).

Use these tutorials for some nice concepts aroung Java IO APIs.

Related Tags

Tutorials

java io

Java IO (Input/Output) Tutorials

Java IO is a collection of APIs targeted at reading and writing data from various sources to several targets. For example, we can read data from a file or over a network, write to a file or write a response back over the network. This page categorizes the various IO-related common tasks into a logical grouping so …

Creating New Directories in Java

Learn to create a new single directory or nested directory along with parent directories in a specified path using Java IO and NIO classes.

Writing Byte[] to a File in Java

Learn to write the given byte[] into a file using different solutions. We will be using the Java NIO, Commons IO and Guava APIs that provide simple APIs for this usecase.

Reading a Large File Efficiently in Java

Learn to read all lines from a large file (size in GB) in Java and avoid any performance pitfalls such as very high usage of memory or even OutOfMemoryError if the File is large enough.

Rename or Move a File or Directory in Java

Learn to rename a file or directory at a specified path or move to a new directory in Java. We will learn to use the classes from Standard IO, New IO, Guava and Commons IO.

Getting Filesystem Paths in Java

Learn the difference between path, absolute and canonical paths. Also, learn to get the path of a file in Java using standard IO and New IO classes.

Java FileWriter

The Java FileWriter class is for writing the text to the character-based files using a default buffer size. It uses character encoding default to the platform, if not provided otherwise. FileWriter is usually wrapped by higher-level Writer types, such as BufferedWriter or PrintWriter. FileWriter provides better performance and higher-level, more …

Java InputStreamReader

The Java InputStreamReader class is often used to read characters from files (or network connections) where the bytes represents text. In this Java tutorial, we will learn about InputStreamReader class, its creation and initialization, and its methods which help in reading the data from the source. 1. InputStreamReader class It …

Guide to Java StringReader

Java StringReader represents a character stream whose source is a string. Use it to pass a string to a method that accepts a Reader Type.

Java FileReader

Java FileReader class can be used to read data (stream of characters) from files. In this tutorial, we will learn about FileReader class, its constructors, methods and usages with the help of examples. 1. Introduction The FileReader class is: 2. Creating FileReader To use the FileReader in the application, we …

Appending to a File in Java

Learn to append the data to a file in Java using Standard IO’s BufferedWritter, PrintWriter, FileOutputStream and NIO Files classes.

Copying a Directory in Java

Learn to copy a directory into a new location in Java. Learn to apply FileFilter to include or exclude subdirectories and specific files.

Making a File Read-Only in Java

Learn to make a file read-only in Java. A read-only file can be opened for reading, but we cannot modify or delete the file contents.

Copying a File in Java

Copying a file from one place to another in Java is a common task. Learn to copy files using Java NIO, Commons-IO and Guava APIs.

Guide to Java BufferedWriter

Learn to create BufferedWriter with default, configure custom internal buffer sizes and write characters data into a file using it.

Guide to Java BufferedReader

Learn to create and operate the BufferedReader instance, set default buffer size and read from a file and system console with examples.

Creating a New File in Java

Learn to create a new file using different techniques including NIO Files and Path, IO File, File OutputStream, and open-source libraries.

How Java IO Works Internally?

Learn how Java IO operations are mapped at the machine level; and what all things the hardware does all the time when application is running.

Java Delete Temporary File

Learn how to delete a temporary file in Java. We will see examples to use File.deleteOnExit() and File.delete() methods.

Java Create Temp File or Directory

Learn to create a temp file and directory in Java using the legacy and NIO classes. Also, learn to delete temp files or temp directories on JVM shutdown.

Writing to Temporary File in Java

Learn to create a temporary file and write to it in Java. We will use the code sample used for creating a temporary file example.

Read File to Byte[] in Java

Learn reading data from files into a byte array in Java using NIO Files, FileInputStream, Commons IO FileUtils, and Guava ByteStreams classes.

Guide to Java LineNumberReader

For reading a file line by line, the LineNumberReader class could be used that allows to keep track of which line we are currently processing.

About Us

HowToDoInJava provides tutorials and how-to guides on Java and related technologies.

It also shares the best practices, algorithms & solutions and frequently asked interview questions.