Java came with several I/O classes to support input and output across streams and the filesystem. The following is a list of Java I/O examples including file manipulation, encoding, serialization, and compression with zip and Gzip.
The files
Examples showing creating, reading, writing, modifying files.
- Create a file
- Build a file path
- Change a file's permission
- Read a file with BufferedInputStream
- Read a file with BufferedReader
- Write to a file with FileOutputStream
- Write to a file with BufferedWriter
- Concatenating content to a file
- Delete a file
- Delete files with a certain extension
- Find files with certain extensions
- Rename files with a certain extension
- Copy a file
- Move a file to another repository
- Get the date a file was created
- Get the last modified date of a file
- Change the last modified date of a file
- Make a file a reader-only
- Get the size of a file
- Get File Path
- Get the number of lines in a file
- Check if a file exists
- Check if a file is hidden
- Read UTF-8 encoded data from a
- Write UTF-8 encoded data to a file
- Convert a file to an array of bytes
- Convert an array of bytes to a file
- Convert a String to an InputStream
- Convert an InputStream to a String
- Convert a file to a Hex
- Get the total space of your partition
Serializing a file
Save an Object to a <br /> file
Reading an Object from a
file
Unzip a file from ZIP
Compress a file as GZIP
Unzip a file from GZIP
Compress a serialized object into a <br /> file Unzip a serialized object from a Gzip
Write the data to a temporary file
Delete a temporary file
Get the path of a temporary file
Delete a directory
Copy a directory
Check if a directory is empty
Get the current directory
file
File compression
Compress a file as ZIPUnzip a file from ZIP
Compress a file as GZIP
Unzip a file from GZIP
Compress a serialized object into a <br /> file Unzip a serialized object from a Gzip
Temporary file
Create temporary fileWrite the data to a temporary file
Delete a temporary file
Get the path of a temporary file
Directories
Create a directoryDelete a directory
Copy a directory
Check if a directory is empty
Get the current directory