1 | static S listSomeFiles(File[] files) { |
2 | ret listSomeFiles(asList(files)); |
3 | } |
4 | |
5 | static S listSomeFiles(L<File> files) { |
6 | new StringBuilder buf; |
7 | for (File f : files) { |
8 | boolean isDir = f.isDirectory(); |
9 | S line = (isDir ? "D" : "F") + " " + f.getName(); |
10 | if (!isDir) { |
11 | long size = f.length(); |
12 | S suffix = "B"; |
13 | if (size >= 1024*1024) { |
14 | size = (size+1024*1024-1) / (1024*1024); |
15 | suffix = "MB"; |
16 | } else if (size >= 1024) { |
17 | size = (size+1024-1) / 1024; |
18 | suffix = "KB"; |
19 | } |
20 | line += " (" + size + " " + suffix + ")"; |
21 | } |
22 | buf.append(line).append("\n"); |
23 | } |
24 | ret str(buf); |
25 | } |
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: | #1003184 |
Snippet name: | listSomeFiles - produce some listing of files |
Eternal ID of this version: | #1003184/1 |
Text MD5: | 1330f540226d23d4b855d15d76574b4f |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-05-25 16:30:43 |
Source code size: | 669 bytes / 25 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 666 / 614 |
Referenced in: | [show references] |