Java provides several classes in java.io
package to work with text, stream data, and file system. I have provided several examples on Java Files and Java IO recently. This post is an index of all Java IO articles.
Java IO
- How to Create New File in Java In this post, you will learn how to create a new file in java program and use of “file.separator” system property to make our program platform independent.
- How to delete a File in Java This post explains how to delete a file or empty directory in java, notice that delete doesn’t throw any exception even if directory is not empty and not deleted.
- Java File separator, separatorChar, pathSeparator, pathSeparatorChar Explained with Example Learn about the four separator static variables of File class.
- How to delete non empty directory in Java A recursive program to delete non-empty directories in java.
- Rename file or Move file in Java Learn how easily you can rename a file or move it into other directory in java.
- File Size in Java Learn how to get the file size in java program.
- Get File Extension in Java Java File doesn’t have any method to get file extension, a utility program showing how to get file extension in java.
- Check File Exists in Java Learn how to check if file exists or not in java.
- How to check if File is Directory? Learn how to find out if the file is actually a directory.
- File Last Modified Date in Java Find out how to get last modified date of a file in java.
- Java FileNameFilter Example Learn how to use FileNameFilter to list files with specific extension in java.
- Java File Path, Absolute Path and Canonical Path Explained Learn the difference between different types of file paths in java.
- Java File Permissions Learn how to get the file permissions for the application user in java program and how to set permissions using File class.
- How to set File Permissions in Java Easily using Java 7 PosixFilePermission Learn the pitfalls of using File class to set permissions and why Java 7 PosixFilePermission are the best way to set file permissions in java.
- Copy File in Java Learn how to copy file using Stream, FileChannel, Apache Commons IO and Java 7 Files class and which is the best way to copy file in java.
- Open File in Java Learn how to open a file in associated application using java.awt.Desktop class.
- Read File in Java Learn how to read file using FileReader, BufferedReader, Scanner class and Java 7 Files class and find out how to get encoding support and best way to read file in java.
- Java File Scanner Example Learn how to use Scanner class to read complete file, parse a file based on regular expression and tokens.
- Read a File to String in Java Learn how to read the complete file into a String in java.
- Java read file line by line Learn how to read file line by line in java, good for working with large files in java.
- Write a File in Java Learn how to write a file using FileWriter, BufferedWriter, Java 7 Files class and FileOutputStream and which one to choose based on your project requirements.
- Append Text to File in Java Learn how to append data to existing file in java.
- Java InputStream to File Example Learn how to convert InputStream to file in java using OutputStream.
- Java Random Access File An example showing usage of Java RandomAccessFile to read and write data to specific index in file.
- Download File from URL Learn how to download a file from URL in java program.
- How to write Object to File in Java Learn how to save object to a file in java using Serialization.
- How to read Object from File in Java Learn how to create Object from file in java using Deserialization.
- How to Compile and Run a Java Program in another Java program A misc program showing how can we compile and run java program from another java program.
- Java Property File and Property XML Learn how to read and write property file and property xml files in java.
- Compress File or Directory using Java ZIP In this article, you will learn how to compress a file in ZIP format, the example shows how to recursively compress a directory to ZIP format.
- Java Unzip File Example In this article, you will learn how to decompress a zip archive.
- Java GZIP Example In this article, you will learn how to compress a file in GZIP format and then how to decompress it in Java.
- Java Temp File Java provides API to create temporary files to be used by the program, the file names are random so it’s hard to hack it. Learn how to create temp files in Java and read/write data into them.
Make sure to share it with others and bookmark it for future use.
Source:
https://www.digitalocean.com/community/tutorials/java-io-tutorial