Home » Core Java » io (page 5)

io

Change File Last Modified date in Java example

In this example we are going to see how you can change the “Last Modified” date of a File in your File System in Java. We are simply going to use the setLastModified method of the File class. We are also going to see how you can parse a string with a date format to a Date object which is ...

Read More »

Move Files in Java example

In this example we are going to see how you can move a file to a new location in your File Path. In Java, there is no generic function you can use to do that. Nevertheless, you can use two ways to perform this operation: Use the renameTo function of the File class to do it. Copy the the File ...

Read More »

4 Ways to Copy File in Java

Although Java offers a class that can handle file operations, that is java.io.File, it doesn’t have a copy method that will copy a file to another. The copying action is an important one, when your program has to handle many file related activities. Nevertheless, there are several ways you can perform a file copying operation in Java and we will ...

Read More »

Append content to file in Java example

With this tutorial we shall show you how to use FileWriter and BufferedReader classes in odrer to append content to a file using Java. The idea is very simple.You have an already created File that has some content in it and you want to write new content at the end of the existing one. In order to do that we ...

Read More »

Write file with BufferedWriter example

With this tutorial we shall show you how to use BufferedWriter to write in a simple text file. It is particularly useful to work with BufferedWriter especially when you want to write an array and generally character data to a file. Let’s see the code:             package com.javacodegeeks.java.core; import java.io.BufferedWriter; import java.io.FileWriter; import java.io.IOException; public class ...

Read More »

Read file with BufferedReader example

In this example we are going to see how to use use the BufferedReader class in Java in order to read a simple text file. In Java, there is a number of ways that you can use to read a file, but the BufferedReader class offers one the most efficient and easy to handle tools. Note that the BufferedReader class can ...

Read More »

Set File permissions in Java example

With this example we shall show you how to set file permissions with Java. This is a very important task to take into consideration when you’re working in a shared system. Although this operation is operation system specific, Java offers a generic API that you can use in all platforms. As you know in UNIX systems you can go much ...

Read More »

Construct a File Path in Java example

In this example we will see how to create a File Path in Java. The idea is very simple. You want your program to be able to create a File and store it in a particular File Path in your system. Let’s say that your program wants to create and store a file in your Home directory. The problem is ...

Read More »