Removing random access file in java

I 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 this?

+3
source share
1 answer

You can do it:

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

Edit regarding your comment:

The parameter NetSimView.filenameis represented File, not the Stringone that contains the file path. So simple:

NetSimView.filename.delete();
+4
source

Source: https://habr.com/ru/post/1766616/


All Articles