package com.record.example;
import java.io.IOException;
import java.nio.file.*;
import java.nio.file.attribute.BasicFileAttributes;
/**
* @className : GetFileName.java
* @author :
* @mtime : 2018-12-17 13:42:44
*/
public class GetFileName {
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
Path initPath = Paths.get("E:\\ant");
Files.walkFileTree(initPath, new SimpleFileVisitor<Path>() {
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
throws IOException {
System.out.println(file.getFileName().toString());
return FileVisitResult.CONTINUE;
}
});
}
}
Java 7中可以使用NIO.2的文件遍历
最新推荐文章于 2024-05-06 13:48:06 发布