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(); final int rndnum = this.rnd.nextInt();
buffer.append(System.currentTimeMillis()); buffer.append(System.currentTimeMillis());
buffer.append('.'); buffer.append('.');
final Formatter formatter = new Formatter(buffer, Locale.ROOT); try (Formatter formatter = new Formatter(buffer, Locale.ROOT)) {
formatter.format("%1$016x-%2$08x", this.count, rndnum); formatter.format("%1$016x-%2$08x", this.count, rndnum);
formatter.close(); }
buffer.append('.'); buffer.append('.');
buffer.append(this.hostname); buffer.append(this.hostname);
} }