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

27
LINES

< > BotCompany Repo | #1000702 // Find a file

JavaX source code - run with: x30.jar

1  
!636
2  
!modernid
3  
4  
main {
5  
  static S programID;
6  
  static S searchFor;
7  
  
8  
  psvm {
9  
    if (args.length == 0) {
10  
      print("I search for files under the current directory.");
11  
      print("Syntax: " + programID + " filetosearch");
12  
    }
13  
    searchFor = args[0];
14  
15  
    scan(".");
16  
  }
17  
  
18  
  static void scan(S file) {
19  
    File f = new File(file);
20  
    if (f.getName().equalsIgnoreCase(searchFor))
21  
      print("Found " + (f.isFile() ? "file" : "dir") + ": " + f.getPath());
22  
    if (f.isDirectory()) {
23  
      File[] l = f.listFiles();
24  
      if (l != null) for (x : l) scan(x);
25  
    }
26  
  }
27  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1000702
Snippet name: Find a file
Eternal ID of this version: #1000702/1
Text MD5: 7e804e89a0c95c1ecffd98917235dd81
Author: stefan
Category:
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-08-23 14:47:44
Source code size: 601 bytes / 27 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 581 / 555
Referenced in: [show references]