A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© tonygone 中级黑马   /  2013-7-18 12:55  /  1121 人查看  /  3 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

  1. public class moveFile {

  2.     private static String oldPath = null;

  3.     public static void main(String[] args) {
  4.         oldPath = "D:\\Download";
  5.         findFile(oldPath);
  6.     }

  7.     public static void findFile(String path) {
  8.         File f = new File(path);
  9.         File[] fileNames = f.listFiles();

  10.         for (File child : fileNames) {
  11.             if (child.getName().matches("^a"))
  12.                 System.out.println(child.getName());
  13.         }
  14.     }
  15. }
复制代码
文件夹下面有以“a” 开头的文件 为什么不输出呢

评分

参与人数 1技术分 +1 收起 理由
杨兴庭 + 1

查看全部评分

3 个回复

正序浏览
[^abc] 任何字符,除了 a、b 或 c(否定)
回复 使用道具 举报
if (child.getName().matches("^a%$"))
回复 使用道具 举报
startsWith("a")试试看~~~
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马