Java IO Tutorial

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 IO recently, this post is an index of all those posts and will keep growing as and when I will add new java IO tutorials.

JAVA-IO

  1. 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.

  2. 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.

  3. Java File separator, separatorChar, pathSeparator, pathSeparatorChar Explained with Example

    Learn about the four separator static variables of File class.

  4. How to delete non empty directory in Java

    A recursive program to delete non-empty directories in java.

  5. Rename file or Move file in Java

    Learn how easily you can rename a file or move it into other directory in java.

  6. File Size in Java

    Learn how to get the file size in java program.

  7. 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.

  8. Check File Exists in Java

    Learn how to check if file exists or not in java.

  9. How to check if File is Directory?

    Learn how to find out if the file is actually a directory.

  10. File Last Modified Date in Java

    Find out how to get last modified date of a file in java.

  11. Java FileNameFilter Example

    Learn how to use FileNameFilter to list files with specific extension in java.

  12. Java File Path, Absolute Path and Canonical Path Explained

    Learn the difference between different types of file paths in java.

  13. 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.

  14. 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.

  15. 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.

  16. Open File in Java

    Learn how to open a file in associated application using java.awt.Desktop class.

  17. 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.

  18. Java File Scanner Example

    Learn how to use Scanner class to read complete file, parse a file based on regular expression and tokens.

  19. Read a File to String in Java

    Learn how to read the complete file into a String in java.

  20. How to read file line by line in Java

    Learn how to read file line by line in java, good for working with large files in java.

  21. 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.

  22. Append Text to File in Java

    Learn how to append data to existing file in java.

  23. Java InputStream to File Example

    Learn how to convert InputStream to file in java using OutputStream.

  24. Java Random Access File

    An example showing usage of Java RandomAccessFile to read and write data to specific index in file.

  25. Download File from URL

    Learn how to download a file from URL in java program.

  26. How to write Object to File in Java

    Learn how to save object to a file in java using Serialization.

  27. How to read Object from File in Java

    Learn how to create Object from file in java using Deserialization.

  28. 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.

  29. Java Property File and Property XML

    Learn how to read and write property file and property xml files in java.

  30. 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.

  31. Java Unzip File Example

    In this article, you will learn how to decompress a zip archive.

  32. 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.

  33. Java Temp File

    Java provides API to create temporary files to be used by 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.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Current ye@r *

Subscribe to JournalDev Newsletter
Get the FREE access to Monthly Newsletter and Free PDF eBooks
*No Spam Guaranteed. By entering your email address, you agree also subscribing to our newsletter.
Oops! - Something went wrong.
Close
Today's Special: Java Persistence API PDF eBook Free Download Now
India's Independence Day Special: Java Persistence API eBook Free Download Now