static S listSomeFiles(File[] files) {
ret listSomeFiles(asList(files));
}
static S listSomeFiles(L<File> files) {
new StringBuilder buf;
for (File f : files) {
boolean isDir = f.isDirectory();
S line = (isDir ? "D" : "F") + " " + f.getName();
if (!isDir) {
long size = f.length();
S suffix = "B";
if (size >= 1024*1024) {
size = (size+1024*1024-1) / (1024*1024);
suffix = "MB";
} else if (size >= 1024) {
size = (size+1024-1) / 1024;
suffix = "KB";
}
line += " (" + size + " " + suffix + ")";
}
buf.append(line).append("\n");
}
ret str(buf);
}
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: | 1021 / 962 |
| Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) |