Java I/O Tutorial
Java comes with many handy I/O classes to support the input and output through bytes stream and file system. Here’s a list of the Java I/O examples including file, temporary file and directory manipulation, encoding, serialized and also compression with zip or Gzip.
Happy learning Java I/O :)
List of the File examples to show the use of Java I/O to create, read, write, modify file and get the file’s information.
- Create a file
- Construct file path
- Set the file permission
- Read file with BufferedInputStream
- Read file with BufferedReader
- Write file with FileOutputStream
- Write file with BufferedWriter
- Append content to file
- Delete a file
- Delete files with certain extension only
- Find files with certain extension only
- Rename a file
- Copy a file
- Move a file to another directory
- Get the file creation date
- Get the file last modified date
- Change the file last modified date
- Make a file read only
- Get file size
- Get the filepath of a file
- Get the total number of lines of a file
- Check if a file exists
- Check if a file is hidden
- Read UTF-8 encoded data from a file
- Write UTF-8 encoded data into a file
- Assign file content into a variable
- Generate a file checksum value
- Convert File into an array of bytes
- Convert array of bytes into File
- Convert String to InputStream
- Convert InputStream to String
- Convert File to Hex
- Get total of free disk space in your partition or volume
Take any object that implements the Serialization interface, convert it into bytes and store it into file; The file can be fully restore back to the original object later.
File compression examples, ZIP and GZip.
- Compress files in ZIP format
- Decompress files from a ZIP file
- Compress a file in GZIP format
- Decompress file from GZIP file
- Compress serialized object into file
- Decompress serialized object from a Gzip file
List of the temporary file manipulation examples.
- Create a temporary file
- Write data to temporary file
- Delete temporary file
- Get the temporary file path
List of the directory manipulation examples.
- Create directory
- Delete directory
- Copy directory
- Traverse /List a directory structure
- Check if directory is empty
- Get the current working directory
List of the Console IO examples.