Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
18
Task/Delete-a-file/Groovy/delete-a-file.groovy
Normal file
18
Task/Delete-a-file/Groovy/delete-a-file.groovy
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
// Gets the first filesystem root. On most systems this will be / or c:\
|
||||
def fsRoot = File.listRoots().first()
|
||||
|
||||
// Create our list of files (including directories)
|
||||
def files = [
|
||||
new File("input.txt"),
|
||||
new File(fsRoot, "input.txt"),
|
||||
new File("docs"),
|
||||
new File(fsRoot, "docs")
|
||||
]
|
||||
|
||||
/*
|
||||
We use it.directory to determine whether each file is a regular file or directory. If it is a directory, we delete
|
||||
it with deleteDir(), otherwise we just use delete().
|
||||
*/
|
||||
files.each{
|
||||
it.directory ? it.deleteDir() : it.delete()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue