jw
try { val bytes = data.toByteArray() ctx.openFileOutput(...).use { it.write(bytes) } } catch (e: IOException) { ... }