Checking to see existance of a file before creating one.
Posted on 2001-08-14
I am creating a servlet where in the Init() method, I am creating a file. however, I need to modify it and am not sure how to do it.
when the servlet is loaded, and the init method called, I need to first check to see if there is an existing file before before creating the file. This is to ensure that I do not overwrite the data from a day before. This is the code that I have currently to create a new file. Could you please modify it to include the logic to check to see if this particular file exists in the given directory before creating it. Thanks,
//Now to set up the Performance log File initially when the servlet is loaded
outputFile = new File("/u/iscdev/Performance/Performance.txt");
out = new RandomAccessFile(outputFile, "rw");