Java 实例 - 查看系统根目录

Java 教程 · 2019-02-11 08:44:26

以下实例演示了使用 File 类的 listRoots() 方法来输出系统所有根目录:

Main.java 文件

import java.io.*; class Main{ public static void main(String[] args){ File[] roots = File.listRoots(); System.out.println("系统所有根目录:"); for (int i=0; i < roots.length; i++) { System.out.println(roots[i].toString()); } } }

以上代码运行输出结果为:

系统所有根目录:
C:\
D:\
E:\
F:\
G:\
H:\

点击查看所有 Java 教程 文章: https://www.codercto.com/courses/l/12.html

查看所有标签

Software Paradigms

Software Paradigms

Stephen H. Kaisler / Wiley-Interscience / 2005-03-17 / USD 93.95

Software Paradigms provides the first complete compilation of software paradigms commonly used to develop large software applications, with coverage ranging from discrete problems to full-scale applic......一起来看看 《Software Paradigms》 这本书的介绍吧!

在线进制转换器
在线进制转换器

各进制数互转换器

MD5 加密
MD5 加密

MD5 加密工具

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具