我正在尝试将一些消息写入文本文件。文本文件位于服务器路径中。我能够从该文件中读取内容。但我无法将内容写入该文件。我收到 FileNotFoundException: \wastServer\apps\LogPath\message.txt(拒绝访问)。
注意:文件具有读写权限。
但是我在哪里做错了。请在下面找到我的代码。
代码:
String FilePath = "\\\\wastServer\\apps\\LogPath\\message.txt";
try {
File fo = new File(FilePath);
FileWriter fw=new FileWriter(fo);
BufferedWriter bw=new BufferedWriter(fw);
bw.write("Hello World");
bw.flush();
bw.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
请帮我解决这个问题?