removing .dat file only while creating the new file
I am stuck up in an odd situation, actually i had a job which creates the
file in a separate folder and the job run daily so every day it creates
the file in that folder and the file is with .dat extension along with
it's zip file .
now let say if the job run today it will create two file in that folder
and the next day I want that zip file of the previous day to be remain
there in that folder but the .dat file should be get deleted before the
.dat file of present day get created , i have write the code but it is not
happening as I want please advise how to achieve this
File file = new File(ilePath + s); //filepath contains the location where
the file will be get created and s contain the filename
for (File f : new File(mcrpFilePath).listFiles()) { // For
each
// dat
// file in
// the
// directory,
// delete
// it.
if (f.isFile()
&&
file.getName().toLowerCase().endsWith(".dat"))
{
f.delete();
}
}
file.createNewFile();
No comments:
Post a Comment