我有一個艱難的時間刪除文件。我會告訴你什麼是工作,如果這是可以接受的,你可以成爲法官。Grails/Groovy文件刪除
class StupidService{
def doThings(){
def tmpDirString = "dumpit"
def currentDir = new File("../${tempDirString}")
currentDir.eachFile(FileType.FILES){
def f=it
def answer = SuperComplicatedService.doStuff(f)
//this works, now I need to move the file to the "done" folder
File dir = new File("../${tempDirString}/done");
def endupFile = new File("../${tempDirString}/done/${f.name}")
FileUtils.copyFile(f, endupFile)
//this works; the file is copied to where I want it successfully; now I just need to delete the initial file.
def thisIsAJoke=0
while(f.delete()==false){
println "This is not a joke: ${thisIsAJoke}"
thisIsAJoke++
}
}
}
}
,因此這打印出40K和150K線之間「這不是一個笑話:64457」等等,最後刪除該文件。
這是怎麼回事?