Java 实例 - 在指定目录中查找文件

Java 教程 · 2019-02-11 06:56:36

以下实例演示了使用 File 类的 dir.list() 方法在指定目录中查找所有文件列表:

Main.java 文件

import java.io.File; public class Main { public static void main(String[] argv) throws Exception { File dir = new File("../java"); 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); } } } }

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

Car.class
FileUtil.class
FileUtil.java
HelloWorld.class
HelloWorld.java
HelloWorldDebug.class
HelloWorldDebug.java
……

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

查看所有标签

XForms Essentials

XForms Essentials

Micah Dubinko / O'Reilly Media, Inc. / 2003-08-27 / USD 29.95

The use of forms on the Web is so commonplace that most user interactions involve some type of form. XForms - a combination of XML and forms - offers a powerful alternative to HTML-based forms. By pro......一起来看看 《XForms Essentials》 这本书的介绍吧!

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

SHA 加密
SHA 加密

SHA 加密工具

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

HEX HSV 互换工具