姜尚
02/21/2023, 2:29 AMKirill Grouchnikov
02/21/2023, 4:18 AM姜尚
02/21/2023, 4:48 AM// Here is my code
fun loadingConfig() {
val file = File("config.json")
if (!file.exists()) {
try {
val content = "{}"
file.createNewFile()
file.writeText(content)
} catch (e: IOException) {
e.printStackTrace()
}
}
val content = readFile("config.json")
}
fun main() {
loadingConfig()
}
// I packaged and installed my app
// I started him using the command line
CMD
➜ pwd
Path
----
C:\Program Files\Helper
➜ .\Helper.exe
java.io.IOException: 拒绝访问。 // It means to deny access
at java.base/java.io.WinNTFileSystem.createFileExclusively(Native Method)
at java.base/java.io.File.createNewFile(Unknown Source)
at com.sun.helper.MainKt.loadingConfig(Main.kt:93)
at com.sun.helper.MainKt.main(Main.kt:217)
at com.sun.helper.MainKt.main(Main.kt)
Exception in thread "main" java.io.FileNotFoundException: config.json (系统找不到指定的文件。)
at java.base/java.io.FileInputStream.open0(Native Method)
at java.base/java.io.FileInputStream.open(Unknown Source)
at java.base/java.io.FileInputStream.<init>(Unknown Source)
at com.sun.helper.common.FileKt.readFile(file.kt:12)
at com.sun.helper.MainKt.loadingConfig(Main.kt:99)
at com.sun.helper.MainKt.main(Main.kt:217)
at com.sun.helper.MainKt.main(Main.kt)
Failed to launch JVM
Child process exited with code 1
Kirill Grouchnikov
02/21/2023, 5:29 AMSystem.getProperty("user.home")
for a folder that works across different OSes.Desmond van der Meer
02/21/2023, 6:47 AMArjan van Wieringen
02/21/2023, 7:36 AM姜尚
02/22/2023, 2:10 AM