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 138 views
1 answer 212 views
1 answer 176 views
2 answers 143 views
1 answer 154 views
1 answer 161 views
1 answer 171 views
171 views asked Jan 13, 2017 by avibootz
...