Java 实例 - 输出指定目录下的所有文件

Java 教程 · 2019-02-11 08:14:14

以下实例演示了如何使用 File 类的 list 方法来输出指定目录下的所有文件:

Main.java 文件

class Main { public static void main(String[] args) { File dir = new File("C:"); String[] children = dir.list(); if (children == null) { System.out.println( "目录不存在或它不是一个目录"); } else { for (int i=0; i< children.length; i++) { String filename = children[i]; System.out.println(filename); } } } }

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

build
build.xml
destnfile
detnfile
filename
manifest.mf
nbproject
outfilename
src
srcfile
test

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

查看所有标签

Text Algorithms

Text Algorithms

Maxime Crochemore、Wojciech Rytter / Oxford University Press / 1994

This much-needed book on the design of algorithms and data structures for text processing emphasizes both theoretical foundations and practical applications. It is intended to serve both as a textbook......一起来看看 《Text Algorithms》 这本书的介绍吧!

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具