How to list out all system drives in your system
Published: January 16, 2010 , Updated: January 11, 2010 , Author: mkyong
File.listRoots() will list out all the available file system roots / drives in your current system.
Example
package com.mkyong.io; import java.io.File; public class App{ public static void main (String args[]) { File[] rootDrive = File.listRoots(); for(File sysDrive : rootDrive){ System.out.println("Drive : " + sysDrive); } } }
Output
Drive : A:\ Drive : C:\ Drive : D:\ Drive : E:\
Any Java questions or problems? please post at this JavaNullPointer.com forum, see you there ~
Your writing is very useful, thank you very much.