Use try-with-resources

This commit is contained in:
Gary Gregory 2022-07-06 10:56:04 -04:00
parent 1cd12fc1dc
commit dca9108352
1 changed files with 3 additions and 3 deletions

View File

@ -65,9 +65,9 @@ class BasicIdGenerator {
final int rndnum = this.rnd.nextInt();
buffer.append(System.currentTimeMillis());
buffer.append('.');
final Formatter formatter = new Formatter(buffer, Locale.ROOT);
formatter.format("%1$016x-%2$08x", this.count, rndnum);
formatter.close();
try (Formatter formatter = new Formatter(buffer, Locale.ROOT)) {
formatter.format("%1$016x-%2$08x", this.count, rndnum);
}
buffer.append('.');
buffer.append(this.hostname);
}