In this section, you will learn to get all directories in your system.
Listing the File System Roots
In this example we will list out all the drives in the disk. This requires an array of File class where all the drives will get stored by using only one method.
listRoots(): It is the method of the File class. It lists the name of the drives.
Code of this example is given below:
import java.io.*;
|
output is given below:
C:\ListSystemRoots>java ListSystemRoots A:\ C:\ D:\ E:\ F:\ G:\ |