在可执行 JAR 中创建文本文件

Creating Textfiles within executable JAR

我创建了一个 java 应用程序,运行 没问题,我已将其导出为 jar。 jar 导出也 运行s 正确,除了一个问题:

当我 运行 它例如在桌面上,它会在桌面上创建 csv 文件。

有没有一种方法可以创建 csv 文件并在 JAR 中立即使用它们,而无需在后台创建它们,例如在桌面上。

我创建了如下的 csv 文件

FileWriter training = new FileWriter("TrainingsdatenStatischDynamisch.csv");

感谢您的帮助!!!

Is there a way to create csv files and using them at once within JAR without creating them in the background e.g. on the desktop.

你不能在 jar 中创建文件,所以它们必须去某个地方。

打开文件的方式将转到您的本地目录,在 gui 系统中可能是您​​的桌面。

您可以打开文件指定更好的路径名,例如 /tmp/filename 或类似的(注意是 linux 路径名)。

您也可以通过更改应用程序启动设置将工作目录设置为您的主目录或其他位置来解决问题。

虽然不确定您使用的是什么操作系统或图形用户界面。