Question: I am trying to write some message to text file. The text file is in the server path. I am able to read content from that file. But i am unable to write content to that file. I am getting FileNotFoundException: \wastServer\apps\LogPath\message.txt (Access Denied).

Note: File has a read and write permissions.

But where i am doing wrong. Please find my code below.

Code:

```
    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();
    }

```

Please help me on this?

Answer: 
Please check whether you can access the `apps` and `LogPath` directory.

Type these on Run (Windows Key + R) 

```
\\\\wastServer\\apps\\

\\\\wastServer\\apps\\LogPath\\

```

And see whether you can access those directories from the machine and user you are executing the above code.
You don't have write access to the share, one of the directories, or the file itself. Possibly the file is already open.