Created
February 3, 2023 18:44
-
-
Save tdcolvin/542d302a8102c6bcaeb0cdc887de7883 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun writeToEncryptedFile(content: String) { | |
//Open the file for writing, and write our contents to it. | |
//Note how Kotlin's 'use' function correctly closes the resource after we've finished, | |
//regardless of whether or not an exception was thrown. | |
encryptedFile.openFileOutput().use { | |
it.write(content.toByteArray(StandardCharsets.UTF_8)) | |
it.flush() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment