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.
After this line

```
 File fo = new File(FilePath);

```

try to print the absolute path

```
System.out.println( fo.getAbsolutePath() );

```

And then check whether the file exists in that location, instead of directly checking at

```
\\\\wastServer\\apps\\LogPath\\message.txt

```

So , you will know, where the compiler is searching for the file.