Java获取文件夹下所有文件名称的方法示例
作者:流风,飘然的风 时间:2023-08-08 08:01:26
本文实例讲述了Java获取文件夹下所有文件名称的方法。分享给大家供大家参考,具体如下:
import java.io.File;
public class GetFoldFileNames {
/**
*
* @author zdz8207
*/
public static void main(String[] args) {
getFileName();
}
public static void getFileName() {
String path = "G:/lxz/20130611"; // 路径
File f = new File(path);
if (!f.exists()) {
System.out.println(path + " not exists");
return;
}
File fa[] = f.listFiles();
for (int i = 0; i < fa.length; i++) {
File fs = fa[i];
if (fs.isDirectory()) {
System.out.println(fs.getName() + " [目录]");
} else {
System.out.println(fs.getName());
}
}
}
}
希望本文所述对大家java程序设计有所帮助。
标签:Java,文件夹,文件名称
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Java编码摘要算法实例解析
2022-07-21 23:33:29
Android实现 EditText输入手机号空格功能
2021-09-17 00:29:27
Spring Boot整合Web项目常用功能详解
2023-06-04 17:14:21
C#用Topshelf创建Windows服务的步骤分享
2022-10-19 00:47:58
![](https://img.aspxhome.com/file/2023/4/76414_0s.png)
RadioButton实现选择后可取消选择
2023-10-15 23:50:39
![](https://img.aspxhome.com/file/2023/3/108243_0s.jpg)
Android ViewPager相册横向移动的实现方法
2023-02-19 07:26:08
![](https://img.aspxhome.com/file/2023/6/139436_0s.jpg)
android自定义简单时钟
2022-01-10 03:00:22
![](https://img.aspxhome.com/file/2023/5/123265_0s.jpg)
获取Android签名证书的公钥和私钥的简单实例
2022-10-02 22:20:13
Java 多层嵌套JSON类型数据全面解析
2022-07-18 05:13:05
![](https://img.aspxhome.com/file/2023/3/85543_0s.jpg)
Android点击EditText文本框之外任何地方隐藏键盘的解决办法
2022-12-19 14:24:41
C语言结构体版学生成绩管理系统
2021-11-05 03:29:41
JAVA中的字符串常量池使用操作代码
2021-11-24 02:00:57
![](https://img.aspxhome.com/file/2023/2/66932_0s.png)
C#将Excel转成PDF的方法
2021-06-13 01:46:09
Java static关键字详细解析
2021-08-12 00:40:23
java线程并发控制同步工具CountDownLatch
2022-09-02 12:18:06
![](https://img.aspxhome.com/file/2023/1/75461_0s.jpg)
java实现简单石头剪刀布小游戏
2021-09-17 07:25:41
![](https://img.aspxhome.com/file/2023/4/63784_0s.jpg)
Springboot异常日志输出方式
2022-04-14 05:38:27
![](https://img.aspxhome.com/file/2023/3/85503_0s.png)
C#使用Aforge调用摄像头拍照的方法
2022-02-10 02:34:36
![](https://img.aspxhome.com/file/2023/9/96369_0s.png)
SpringBoot统一响应格式及统一异常处理
2022-08-30 08:03:08
![](https://img.aspxhome.com/file/2023/5/63155_0s.png)
Android App页面滑动标题栏颜色渐变详解
2023-10-14 20:08:17