Home » Core Java » apache » commons » io » Page 2

io

Get Disk Free Space

This is an example of how to get the Disk free space in Java. We are using the org.apache.commons.io.FileSystemUtils class that provides static utility methods for general file system functions not provided via the JDK File class. Getting the free space of a Disk implies that you should: Use freeSpaceKb(String path) that returns the free space on a drive or volume ...

Read More »

Get directory size

In this example we shall show you how to get the size of a directory. We are using the org.apache.commons.io.FileUtils class that provides general file manipulation utilities. To get the size of a directory one should perform the following steps: Create a String with the path to the directory. Create a new File instance by converting the given pathname string into an ...

Read More »

Create a copy of a file

With this example we are going to demonstrate how to create a copy of a file. We will make use of the org.apache.commons.io.FileUtils class, that provides file manipulation utilities. In short, to create a copy of a file you should: Create a new File by converting the given pathname string of the initial file into an abstract pathname. Create a ...

Read More »

Get content of a file line by line

This is an example of how to get the content of a file, line by line. We will make use of the org.apache.commons.io.FileUtils class, that provides file manipulation utilities. Getting the content of a file, line by line implies that you should: Create a new File by converting the pathname string of the file into an abstract pathname. Use readLines(File ...

Read More »

Set content to a file

In this example we shall show you how to set the content to a File. We will make use of the org.apache.commons.io.FileUtils class, that provides file manipulation utilities. To set the content to a File one should perform the following steps: Create a new File by converting the pathname string of the file into an abstract pathname. Create a String ...

Read More »

Get content of a File

With this example we are going to demonstrate how to get the content of a File. We will make use of the org.apache.commons.io.FileUtils class, that provides file manipulation utilities. In short, to get the content of a File you should: Create a new File by converting the pathname string of the file into an abstract pathname. Use readFileToString(File file) API ...

Read More »

touch file using apache commons io example

This is an example of how to touch a file. We will make use of the org.apache.commons.io.FileUtils class, that provides file manipulation utilities. Touching a file implies that you should: Create a new File by converting the pathname string of the file into an abstract pathname. Use lastModified() API method of File that returns the time that the file denoted ...

Read More »