Java 'file.delete()' Is not Deleting Specified File?

Be sure to find out your current working directory, and write your filepath relative to it.

Be sure to find out your current working directory, and write your filepath relative to it. This code: File here = new File(". "); System.out.

Println(here.getAbsolutePath()); ... will print out that directory. Also, unrelated to your question, try to use slashes instead of backslashes, i.e. / and not \ when you write filepaths.

Backslashes work only on Windows.

Thanks! It was the fact that I didn't have the whole path in there. I knew it was something simple that I was completely missing!P.

S - Thanks for the tip about slashes. – Kimberley Lloyd Dec 19 '10 at 23:31.

I suspect that the problem is that the path is incorrect. Try this: UserInput. Prompt("Enter name of file to delete"); String name = UserInput.readString(); File file = new File("\\Files\\" + name + ".

Txt"); if (file.exists()) { file.delete(); } else { System.err. Println( "I cannot find '" + file + "' ('" + file.getAbsolutePath() + "')"); }.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions