android: Cleanup classes

- Use final modifer wherever possible
- Use try-with-resources for input/output streams

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
Harsh Shandilya
2018-06-02 19:14:56 +02:00
committed by Jason A. Donenfeld
parent 4986d92f3d
commit 4671f59c67
11 changed files with 41 additions and 40 deletions
@@ -42,7 +42,7 @@ public final class FileConfigStore implements ConfigStore {
final File file = fileFor(name);
if (!file.createNewFile())
throw new IOException("Configuration file " + file.getName() + " already exists");
try (FileOutputStream stream = new FileOutputStream(file, false)) {
try (final FileOutputStream stream = new FileOutputStream(file, false)) {
stream.write(config.toString().getBytes(StandardCharsets.UTF_8));
}
return config;
@@ -70,7 +70,7 @@ public final class FileConfigStore implements ConfigStore {
@Override
public Config load(final String name) throws IOException {
try (FileInputStream stream = new FileInputStream(fileFor(name))) {
try (final FileInputStream stream = new FileInputStream(fileFor(name))) {
return Config.from(stream);
}
}
@@ -95,7 +95,7 @@ public final class FileConfigStore implements ConfigStore {
final File file = fileFor(name);
if (!file.isFile())
throw new FileNotFoundException("Configuration file " + file.getName() + " not found");
try (FileOutputStream stream = new FileOutputStream(file, false)) {
try (final FileOutputStream stream = new FileOutputStream(file, false)) {
stream.write(config.toString().getBytes(StandardCharsets.UTF_8));
}
return config;