@@ -0,0 +1,2962 @@
+package com.github.booknara.nioexample;%0A%0Aimport java.io.File;%0Aimport java.io.IOException;%0Aimport java.nio.file.*;%0Aimport java.nio.file.attribute.BasicFileAttributes;%0A%0A/**%0A * Created by zeropc on 2/16/16.%0A */%0Apublic class FilesExample %7B%0A    public static void main(String%5B%5D args) %7B%0A        Path path = Paths.get(%22.%22, %22colors.xml%22);%0A%0A        boolean exist = Files.exists(path, new LinkOption%5B%5D %7B LinkOption.NOFOLLOW_LINKS %7D );%0A        if (exist)%0A            System.out.println(%22The file exists!%22);%0A        else%0A            System.out.println(%22The file doesn't exist!%22);%0A%0A        Path copyFile = Paths.get(%22.%22, %22colors-copy.xml%22);%0A        Path moveFile = Paths.get(%22.%22, %22colors-move.xml%22);%0A        try %7B%0A            // Copy operation%0A            Files.copy(path, copyFile);%0A            // Files.copy(path, copyFile, StandardCopyOption.REPLACE_EXISTING);%0A%0A            // Move operation%0A            Files.move(path, moveFile, StandardCopyOption.REPLACE_EXISTING);%0A%0A            // Delete operation%0A            Files.delete(copyFile);%0A            Files.delete(moveFile);%0A        %7D catch (FileAlreadyExistsException e) %7B%0A            System.out.println(e.getStackTrace());%0A        %7D catch (IOException e) %7B%0A            System.out.println(e.getStackTrace());%0A        %7D%0A%0A        Path subPath = Paths.get(%22.%22, %22subdir%22);%0A%0A        try %7B%0A            Path newPath = Files.createDirectory(subPath);%0A            boolean folderExist = Files.exists(newPath, new LinkOption%5B%5D %7B LinkOption.NOFOLLOW_LINKS %7D );%0A            if (folderExist)%0A                System.out.println(%22The new folder exists!%22);%0A            else%0A                System.out.println(%22The new folder doesn't exist!%22);%0A%0A        %7D catch (IOException e) %7B%0A            System.out.println(e.getStackTrace());%0A        %7D%0A%0A        Path currentPath = Paths.get(%22.%22);%0A%0A        try %7B%0A            Files.walkFileTree(currentPath, new SimpleFileVisitor%3CPath%3E() %7B%0A                @Override%0A                public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException %7B%0A                    return super.preVisitDirectory(dir, attrs);%0A                %7D%0A%0A                @Override%0A                public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException %7B%0A                    System.out.println(%22File name : %22 + file.toAbsolutePath().toString());%0A                    return FileVisitResult.CONTINUE;%0A                %7D%0A%0A                @Override%0A                public FileVisitResult visitFileFailed(Path file, IOException exc) throws IOException %7B%0A                    return super.visitFileFailed(file, exc);%0A                %7D%0A%0A                @Override%0A                public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException %7B%0A                    return super.postVisitDirectory(dir, exc);%0A                %7D%0A            %7D);%0A        %7D catch (IOException e) %7B%0A            System.out.println(e.getStackTrace());%0A        %7D%0A%0A%0A    %7D%0A%7D%0A

Add FilesExample file