views:

44

answers:

1

I've created a random access file as follows:

 RandomAccessFile aFile = null;
 aFile = new RandomAccessFile(NetSimView.filename, "rwd");

I want to delete the file "afile". can anyone suggest me how to do it?

+2  A: 

You can do that:

File f = new File(NetSimView.filename);
f.delete();

Edit, regarding your comment:

The parameter NetSimView.filename seems to be a File and not a String that contains the path to the file. So simply do:

NetSimView.filename.delete();
romaintaz
Or `(new File(NetSimView.filename)).delete();`.
larsmans
@romaintiaz :Thanks for your answer but the above code is giving an error: cannot find symbol Symbol:Constructor File(java.io.File)
Harshit Agarwal
`NetSimView.filename` is a `File` class, then? Read my edit.
romaintaz