Use try-with-resources.

This commit is contained in:
Isira Seneviratne 2020-11-06 06:16:13 +05:30
parent 8bcf0c6498
commit 95333d37c8
8 changed files with 84 additions and 137 deletions

View file

@ -37,14 +37,12 @@ public final class LicenseFragmentHelper {
@NonNull final License license) {
final StringBuilder licenseContent = new StringBuilder();
final String webViewData;
try {
final BufferedReader in = new BufferedReader(new InputStreamReader(
context.getAssets().open(license.getFilename()), StandardCharsets.UTF_8));
try (BufferedReader in = new BufferedReader(new InputStreamReader(
context.getAssets().open(license.getFilename()), StandardCharsets.UTF_8))) {
String str;
while ((str = in.readLine()) != null) {
licenseContent.append(str);
}
in.close();
// split the HTML file and insert the stylesheet into the HEAD of the file
webViewData = licenseContent.toString().replace("</head>",