To retrieve drive names from a system, use the static method listRoots in java.io.File package. It will return the all-available drive present in the system. This method will be useful when customizing applications to perform Input Output operations. The listRoots method returns an array of File Objects.
import java.io.File;class Drive{ static void main(String[]arr) { File[]f=File.listRoots(); for(int i=0;i