-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAuditReport.java
More file actions
45 lines (38 loc) · 1.03 KB
/
AuditReport.java
File metadata and controls
45 lines (38 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import java.io.BufferedWriter;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class AuditReport {
List<FileRecord> records = new ArrayList<>();
void addRecord(FileRecord rec) {
records.add(rec);
}
int fileCount() {
Set<Path> set = new HashSet<>();
for (FileRecord r : records) {
set.add(r.file);
}
return set.size();
}
void printOverview() {
System.out.println("\nTotal files inspected: " + fileCount());
}
void printDetails() {
for (FileRecord r : records) {
System.out.println(r);
}
}
void saveToFile() throws IOException {
BufferedWriter bw = Files.newBufferedWriter(Paths.get("audit_log.txt"));
for (FileRecord r : records) {
bw.write(r.toString());
bw.newLine();
}
bw.close();
}
}