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).

!7

import java.nio.file.*;
import java.nio.file.attribute.*;

p {
  final Path mainPath = FileSystems.getDefault().getPath(userHome());
  
  Files.walkFileTree(mainPath, new SimpleFileVisitor<Path>() {
    @Override
    public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
      print("Dir: " + dir);
      return eq(dir, mainPath) ? FileVisitResult.CONTINUE : FileVisitResult.SKIP_SUBTREE;
    }
  
    @Override
    public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
      // here you have the files to process
      bool dir = attrs.isDirectory(); // always false I guess
      bool sym = attrs.isSymbolicLink();
      print((sym ? "SYMLINK: " : dir ? "DIR: " : "FILE: ") + file);
      return sym || dir ? FileVisitResult.SKIP_SUBTREE : FileVisitResult.CONTINUE;
    }
    
    @Override
    public FileVisitResult visitFileFailed(Path file, IOException exc) throws IOException {
      print("OOPS: " + file);
      return FileVisitResult.CONTINUE;
    }
  });
}

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: 710 / 803
Version history: 10 change(s)
Referenced in: