devxlogo

Retrieving Drive Names

Retrieving Drive Names

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

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist