简单的文件读取

来源:互联网 发布:网络布线用到工具 编辑:程序博客网 时间:2024/05/16 06:30
public static void main(String[] args) {         File file=new File("d:/");         fileList(file);    } public static void fileList(File file) {        File[] files = file.listFiles();        if (files != null) {              for (File f : files) {               if("txt".equals(f.getPath().substring(f.getPath().indexOf(".", 0)+1, f.getPath().length()))){                System.out.println(f.getPath());               }              }        }   }