如何在appdata中保存文件

问题描述

我必须使用什么路径来读写appdata中的文件?

我可以使用ImageIo还是必须使用其他东西。我可以使用BufferedReader和BufferedWriter吗?

解决方法

APPDATA是Windows中的环境变量,因此只需构建包含该目录的路径即可,您可以通过System.getenv("APPDATA")获得该路径。

例如,

File imageFile = new File(System.getenv("APPDATA") + "\\whatever\\picture.jpg");

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...