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 239 views
1 answer 303 views
1 answer 255 views
2 answers 264 views
1 answer 273 views
1 answer 262 views
1 answer 255 views
255 views asked Jan 13, 2017 by avibootz
...