【发布时间】:2011-08-24 17:17:54
【问题描述】:
是的,我正在以小程序的形式制作基于文本的 RPG。此小程序在打开时会写入您的 APPDATA 目录。它可以在 IDE 中运行,但是当我在 Firefox 中尝试时,它会出现错误消息。 HERE 是链接。
File otherWorldDirectory = new File(System.getenv("APPDATA") + "\\.otherWorld");
if (!otherWorldDirectory.exists()) {
//Adding the folder .otherWorld to the APPDATA
otherWorldDirectory.mkdir();
System.out.println("Directory '.otherWorld' created.");
} else {
//The folder .otherWorld already exists.
System.out.println("Directory '.otherWorld' is not created, it exists.");
}
【问题讨论】:
-
您不能简单地写入客户端计算机上的本地文件夹 - 这是一个安全漏洞。重新审视你的设计!见this。
-
那怎么办?我需要签署 .jar 文件吗?还是直接保存到其他文件夹?
标签: java access-denied appdata japplet