Libraryless. Click here for Pure Java version (52L/1K/2K).
1 | !636 (modern) |
2 | |
3 | main {
|
4 | psvm {
|
5 | String dirToList = "."; |
6 | File d = new File(dirToList); |
7 | if (d.isDirectory()) {
|
8 | for (File f : d.listFiles()) {
|
9 | boolean isDir = f.isDirectory(); |
10 | S line = (isDir ? "D" : "F") + " " + f.getName(); |
11 | if (!isDir) {
|
12 | long size = f.length(); |
13 | S suffix = "B"; |
14 | if (size >= 1024*1024) {
|
15 | size = (size+1024*1024-1) / (1024*1024); |
16 | suffix = "MB"; |
17 | } else if (size >= 1024) {
|
18 | size = (size+1024-1) / 1024; |
19 | suffix = "KB"; |
20 | } |
21 | line += " (" + size + " " + suffix + ")";
|
22 | } |
23 | print(line); |
24 | } |
25 | } |
26 | } |
27 | } |
Began life as a copy of #638
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, teubizvjbppd, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1000739 |
| Snippet name: | List current directory with sizes (works, shows "D" or "F" and name and size) |
| Eternal ID of this version: | #1000739/1 |
| Text MD5: | b47ee4d1d180b7cca4c6e355915a3f88 |
| Transpilation MD5: | c31a3709f4e2b3c449031e6eed52b747 |
| Author: | stefan |
| Category: | |
| Type: | JavaX source code |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2015-08-27 02:46:04 |
| Source code size: | 698 bytes / 27 lines |
| Pitched / IR pitched: | No / Yes |
| Views / Downloads: | 808 / 856 |
| Referenced in: | [show references] |