Der Code wird in try{} ausgeführt, bis isNewFileCreated, und wechselt dann zu Catch(error: Exception){}
isNewFileCreated ist „false“, aber die Datei existiert nicht
Code: Select all
*`//------------Kotlin:
private var filename: String = "readme.txt"
private lateinit var newFile: File
fun cfile() {
val isNewFileCreated: Boolean
try {
newFile = File("/data/data/com.example.myapplication2/files/",filename)
isNewFileCreated = newFile.createNewFile()
}
catch (error: FileNotFoundException) {
error.printStackTrace();
}
catch (error: Exception) {
error.printStackTrace();
}
}`*
//-------------------
Code: Select all
`//-----kotlin
try {
newFile = File("/data/data/com.example.myapplication2/files/",filename)
isExist = setFile.exists()
val sFile = FileOutputStream(setFile)
sFile.use {
isNewFileCreated = setFile.createNewFile()
}
}
catch { ...`
I assume that this problem is only in the latest versions of SDK.