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 you can refer to various solutions of a particular problem and choose what fits best to your requirements.
1. Working with Files
- Creating a New File
- Reading a File to String
- Reading a File to Byte[]
- Reading a File Line by Line
- Reading a File from Classpath
- Reading a File from Resources Directory
- Writing to a File
- Appending to a File
- Reading and Writing UTF-8 Data
- Rename or Move a File or Directory
- Copying a File
- Deleting a File or Directory
- Getting Size of File or Directory
- Reading a Large File Efficiently
- Reading a File at a Given Line Number
- Reading a CSV File into an Array
- Read a File into an ArrayList
- Count Number of Lines
- Writing byte[] to a File
- Delete the Contents of a File
- Check If a File or Directory Exists
- Getting File Creation Timestamp
- Working with Symbolic Links
- Making a File Read Only
- How to Find a File in Directory
2. Working with Temporary Files
3. Working with Directories
- Creating New Directories
- Check if a Directory is Empty
- Listing All Files in a Directory
- Get Current Working Directory
- Copying a Directory
- Delete a Directory Recursively
- Filtering Files with FileFilter
- Finding Files Matching Pattern with FilenameFilter
4. Conversions
- Convert String to InputStream
- Convert InputStream to String
- Convert InputStream to Reader and Vice Versa
- Convert InputStream to OutputStream
- Convert OutputStream to InputStream
- Reader to String and Vice Versa
- Reader to Byte Array and Vice Versa
- Write a Reader to File and Vice Versa
5. Java Standard IO
6. Java New IO
- Introduction to the Java NIO
- Standard IO vs New IO
- NIO Paths
- Getting Filesystem Paths
- NIO Buffers
- NIO Channels
- Vectored IO
- NIO MappedByteBuffer
- Reading a File with Channels and Buffers
7. Advance Topics
- How does Java IO Works Internally?
- Reading User Input from Console
- Read typesafe input using Scanner class
- Encrypting and Decrypting Files
- Reading and Writing Properties Files
- Java Create Password Protected Zip File
- Java Unzip File with Subdirectories
Leave a Reply