Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

31
LINES

< > BotCompany Repo | #1006959 // Java 7 Incremental Directory Listing [dev.]

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Libraryless. Click here for Pure Java version (524L/4K/14K).

1  
!7
2  
3  
import java.nio.file.*;
4  
import java.nio.file.attribute.*;
5  
6  
p {
7  
  final Path mainPath = FileSystems.getDefault().getPath(userHome());
8  
  
9  
  Files.walkFileTree(mainPath, new SimpleFileVisitor<Path>() {
10  
    @Override
11  
    public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
12  
      print("Dir: " + dir);
13  
      return eq(dir, mainPath) ? FileVisitResult.CONTINUE : FileVisitResult.SKIP_SUBTREE;
14  
    }
15  
  
16  
    @Override
17  
    public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
18  
      // here you have the files to process
19  
      bool dir = attrs.isDirectory(); // always false I guess
20  
      bool sym = attrs.isSymbolicLink();
21  
      print((sym ? "SYMLINK: " : dir ? "DIR: " : "FILE: ") + file);
22  
      return sym || dir ? FileVisitResult.SKIP_SUBTREE : FileVisitResult.CONTINUE;
23  
    }
24  
    
25  
    @Override
26  
    public FileVisitResult visitFileFailed(Path file, IOException exc) throws IOException {
27  
      print("OOPS: " + file);
28  
      return FileVisitResult.CONTINUE;
29  
    }
30  
  });
31  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1006959
Snippet name: Java 7 Incremental Directory Listing [dev.]
Eternal ID of this version: #1006959/11
Text MD5: 25d979bafb92e2bbd8195d430e9c8d23
Transpilation MD5: ec021f20f107e1cd459d5c7bde599494
Author: stefan
Category: javax / io
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-02-20 11:43:14
Source code size: 1084 bytes / 31 lines
Pitched / IR pitched: No / No
Views / Downloads: 640 / 721
Version history: 10 change(s)
Referenced in: [show references]