我正在处理一个 Java 项目。只有一个值存储在此位置的 txt 文件中:(src/files/file.txt)
。
我将项目导出到 jar 文件,我知道因为 src 文件夹,我需要使用以下代码来读取文件。
InputStream stream = MainUi.class.getResourceAsStream("src/files/tax.txt");
但我在这种情况下写入文件时遇到问题,需要更改文件数据。请让我知道如何解决它。
最佳答案
I export the project to jar file and I know that because of the src folder, I need to use the following code to read the file.
您的程序(从可执行 Jar
启动)不可能写入位于同一 Jar
文件内的文本文件。
请看:How can an app use files inside the JAR for read and write?
关于java - 写入 Java 项目文件夹中的 txt 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38168885/