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 🙂
File
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.
- How to create a file in Java
- How to construct a file path in Java
- How to set the file permission in Java
- How to read file in Java – BufferedInputStream
- How to read file in Java – BufferedReader
- How to read file in Java – FileInputStream
- How to write to file in Java – FileOutputStream
- How to write to file in Java – BufferedWriter
- Java create and write to a file
- How to append text to a file in Java
- How to delete a file in Java
- How to find files with the file extension in Java
- How to get file extension in Java
- How to rename or move a file in Java
- How to copy file in Java
- How to move file to another directory in Java
- How to get file creation date in Java
- How to get file last modified date in Java
- Java – Update last modified date of a file
- How to format FileTime in Java
- How to make a file read only in Java
- How to get file size in Java
- How to get the filepath of a file in Java
- Java – Count number of lines in a file
- Java 8 Stream – Read a file line by line
- How to check if a file exists in Java
- How to check if a file is hidden in Java
- How to read a UTF-8 file in Java
- How to write a UTF-8 file in Java
- How to assign file content into a variable in Java
- Java – Create file checksum with SHA and MD5
- Convert File into an array of bytes
- Convert array of bytes into File
- How to convert String to InputStream in Java
- How to convert InputStream to String in Java
- How to convert InputStream to File in Java
- Convert InputStream to BufferedReader in Java
- Java – Convert File to Hex
- Get total of free disk space in your partition or volume
File Serialization
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.
- How to write an object to file in Java (ObjectOutputStream)
- How to read an object from file in Java (ObjectInputStream)
- Java Serialization and Deserialization Examples
- Java – What is serialVersionUID
- Java – How to generate serialVersionUID
- Java – What is transient fields?
- Convert object to byte[] in Java
- How to read and write Java object to a file
File Compression
File compression examples, ZIP and GZip.
- How to create Zip file in Java
- How to unzip a zip file in Java
- Java – Compress a file in Gzip format
- Java – Decompress a Gzip file
- How to create tar.gz in Java
- How to compress serialized object into file
- How to decompress serialized object from a Gzip file
Temporary File
List of the temporary file manipulation examples.
- How to create a temporary file in Java
- How to write data to a temporary file in Java
- How to delete a temporary file in Java
- How to get the temporary file path in Java
- Java – Unable to assign group write permission to a file
Directory
List of the directory manipulation examples.
- How to create directory in Java
- How to delete directory in Java
- How to copy directory in Java
- How to traverse a directory structure in Java
- Java – How to list all files in a directory?
- How to check if directory is empty in Java
- How to get the current working directory in Java
- Java Files.walk examples
- Java Files.find examples
Resources
- Java – Get the name or path of a running JAR file
- Java – Read a file from resources folder
- Java : getResourceAsStream in static method
HTTP Communication
- Apache HttpClient Examples
- How to send HTTP request GET/POST in Java
- OkHttp – How to send HTTP requests
- Java 11 HttpClient Examples
- Java HttpsURLConnection example
- Java HttpURLConnection follow redirect example
- How to automate login a website – Java example
- Java SSLSocket TLS 1.3 example
- How to get HTTP Response Header in Java
- How To Get HTTP Request Header In Java
- How to get client Ip Address in Java
- How to get Server IP address in Java
- File Transfer using SFTP in Java (JSch)
Console IO
List of the Console IO examples.
System Environment
- Java – How to display all System properties
- How to detect OS in Java
- Java Properties file examples
- How to get the environment variables in Java