将文件系统根目录提取为File数组
import java.io.File; public class Main { /** from * nowjava **/ public static void main(String[] args) { File[] roots = File.listRoots(); for (File root : roots) { System.out.println(root); } } }
import java.io.File; public class Main { /** from * nowjava **/ public static void main(String[] args) { File[] roots = File.listRoots(); for (File root : roots) { System.out.println(root); } } }