我有一个具有以下文件结构的项目:
Project
|
+-- storage.bin
|
+-- myfile.jar
在myfile.jar中,我有几行代码:
ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream("./storage.bin"));
out.writeObject(listOfObjects);
out.close();
我打算将此写入项目目录中的storage.bin文件,但实际上它会在我的用户目录中创建并写入一个storage.bin文件。如何创建所需的函数?
注意:我使用的是mac,整个项目结构是mac应用程序的结构
发布于 2019-01-16 08:37:11
./
表示工作路径。
1.
.../Project/
在路径中运行Java。
ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(".../Project/storage.bin"));```
https://stackoverflow.com/questions/54208794
复制相似问题