An example on getting paths of all local drives in a computer in Java.
listRoots(): It is a static method of the java.io.File class and is used to get all the roots (local drives).
Get Local Drive Paths - Example
import java.io.File;
class GetLocalDrives
{
public static void main(String args[])
{
File[] f=File.listRoots();
for(File k:f)
System.out.println(k);
}
}
listRoots(): It is a static method of the java.io.File class and is used to get all the roots (local drives).
Sample Output
C:\ D:\ E:\ F:\ G:\
No comments:
Post a Comment