1、复制
StandardCopyOption.REPLACE_EXISTING:覆盖已有的目标路径
StandardCopyOption.COPY_ATTRIBUTES:复制所有的文件属性
Files.move(Paths.get("/app/test/filename.txt"),Paths.get("/app/test2/filename.txt"),StandardCopyOption.COPY_ATTRIBUTES);
2、移动
Files.move(Paths.get("/app/test/filename.txt"),Paths.get("/app/test2/filename.txt"),StandardCopyOption.REPLACE_EXISTING);
3、判断路径是否存在
Files.exists(Paths.get("/app/test/filename.txt"));
4、创建文件
Files.createDirectories(Paths.get("/app/test/filename.txt"));
Files.createFile(Paths.get("/app/test/filename.txt"));
5、删除文件
Files.deleteIfExists(Paths.get("/app/test/filename.txt"));
6、写入文件
Files.write(Paths.get("/app/test/filename.txt"),bytes,StandardOpenOption.APPEND)
7、批量获取文件路径
Stream<Path> files = Files.list(Paths.get("/app/test/filename.txt"));
files.forEach(path -> doImport(path))