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

查看所有标签

Algorithms Illuminated (Part 2)

Algorithms Illuminated (Part 2)

Tim Roughgarden / Soundlikeyourself Publishing, LLC / 2018-8-5 / USD 17.99

Algorithms are the heart and soul of computer science. Their applications range from network routing and computational genomics to public-key cryptography and machine learning. Studying algorithms can......一起来看看 《Algorithms Illuminated (Part 2)》 这本书的介绍吧!

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

各进制数互转换器

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码