Close InputStream after usage in KeyReader

The `InputStream` would not be closed after reading the key file in `KeyReader#import`, it's now wrapped with `use{ }` which handles closing the stream after usage.
This commit is contained in:
PixelyIon 2022-03-10 12:38:36 +05:30
parent 647cb07dc8
commit 1d070e6332

View File

@ -47,7 +47,7 @@ object KeyReader {
val tmpOutputFile = File("${context.filesDir.canonicalFile}/${keyType.fileName}.tmp") val tmpOutputFile = File("${context.filesDir.canonicalFile}/${keyType.fileName}.tmp")
val inputStream = context.contentResolver.openInputStream(uri) context.contentResolver.openInputStream(uri).use { inputStream ->
tmpOutputFile.bufferedWriter().use { writer -> tmpOutputFile.bufferedWriter().use { writer ->
val valid = inputStream!!.bufferedReader().useLines { val valid = inputStream!!.bufferedReader().useLines {
for (line in it) { for (line in it) {
@ -83,6 +83,7 @@ object KeyReader {
return valid return valid
} }
} }
}
private fun isHexString(str : String) : Boolean { private fun isHexString(str : String) : Boolean {
for (c in str) for (c in str)