我有一个问题让这个工作.它包含一个由几条信息组成的字符串.
但是,当我尝试将String写入文件以便跟踪程序随时间的变化时,我收到一个拒绝访问错误:
void writeToFile(String input) throws Exception{
File file = new File("C:\\WeatherExports\\export.txt");
if(!file.exists()){
file.createNewFile();
}
BufferedWriter inFile = new BufferedWriter(new FileWriter(file,true));
try{
inFile.append(input);
inFile.newLine();
} catch(Exception e){
e.printStackTrace();
}
inFile.close();
}
STACKTRACE YEILDS:
java.io.FileNotFoundException: C:\WeatherExports\export.txt (Access is denied)
完整Stacktrace:
java.io.FileNotFoundException: C:\WeatherExports\export.txt (Access is denied)
at java.io.FileOutputStream.openAppend(Native Method)
at java.io.FileOutputStream.(Unknown Source)
at ja