How can I check that I can delete a file in Java?

For example, I should be able to delete file C:/file.txt but I never will be able to delete the C:/ or Computer, or My Documents etc.

Solution described in possible duplicate does not work for me.

Edit
Report