August 1999
Intermediate to advanced
1488 pages
72h 53m
English
file.exists()
The exists() method of the File object returns a boolean value based on the existence of the file in which it was invoked. If the file exists, the method returns true. It returns false if the file does not exist.
Listing 8.76 opens a file and then checks to see if it exists.
<SERVER>
// Open a log file
var myLog = new File("/data/logs/today.log");
// See if the file exists
if(myLog.exists()){
write('The file exists');
}else{
write('The file does not exist');
}
</SERVER>
|
Read now
Unlock full access