How to get list of available file system root drives in Java

1 Answer

0 votes
package javaapplication1;

import java.io.File;
import java.io.IOException;

public class JavaApplication1 {

    public static void main(String[] args) throws IOException {

        try {

            File[] rootList = File.listRoots();

            for (int i = 0; i < rootList.length; i++) {
                System.out.println(rootList[i]);
            }

        } catch (Exception e) {
            System.out.print(e);
        }
    }
}

/*
         
run:
   
C:\
D:\
E:\
F:\
 
 */

 



answered Nov 18, 2016 by avibootz

Related questions

1 answer 240 views
1 answer 305 views
1 answer 258 views
2 answers 264 views
1 answer 276 views
1 answer 264 views
1 answer 259 views
259 views asked Jan 13, 2017 by avibootz
...