Tarba Dan
Posts: 11
Nickname: dtarba
Registered: May, 2002
|
|
Re: files
|
Posted: May 14, 2002 6:12 AM
|
|
The class RandomAccessFile supports 2 constructors :
RandomAccessFile(File file, String mode) Creates a random access file stream to read from, and optionally to write to, the file specified by the File argument.
RandomAccessFile(String name, String mode) Creates a random access file stream to read from, and optionally to write to, a file with the specified name.
The constructor you used RandomAccessFile(java.lang.String) does not exist.
If you remove the line RandomAccessFile[\b] file1=new RandomAccessFile[\b] ("d:/file.text"); then your code will work and the file will be deleted .
If you want to keep that line then close te file like this :
RandomAccessFile file1=new RandomAccessFile("d:/file.text");
//close the file before opening it again : file1.close();
//now you can open the file File f=new File("d:/file.text");
//and delete it f.delete();
|
|