March 2018
Intermediate to advanced
208 pages
4h 52m
English
| | class Logbook { |
| » | static final Path DIR = Paths.get("/var/log"); |
| | static final Path CSV = DIR.resolve("stats.csv"); |
| | static final String GLOB = "*.log"; |
| | |
| » | void createStats() throws IOException { |
| | try (DirectoryStream<Path> dirStr = |
| | Files.newDirectoryStream(DIR, GLOB); |
| | BufferedWriter bufW = Files.newBufferedWriter(CSV)) { |
| | for (Path lFile : dirStr) { |
| | String csvLn = String.format("%s,%d,%s", |
| | lFile, |
| | Files.size(lFile), |
| | Files.getLastModifiedTime(lFile)); |
| | bufW.write(csvLn); |
| | bufW.newLine(); |
| | } |
| | } |
| | } |
| | } |
Abbreviations are one step up from single-letter names, and our world is full of them: ASAP, FYI, TGIF, AFK, NASA, FBI, CYA, NYPD, and so on. Many programmers like to create their ...