Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
15
Task/Delete-a-file/Scala/delete-a-file.scala
Normal file
15
Task/Delete-a-file/Scala/delete-a-file.scala
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
import java.util._
|
||||
import java.io.File
|
||||
|
||||
object FileDeleteTest extends App {
|
||||
def deleteFile(filename: String) = { new File(filename).delete() }
|
||||
|
||||
def test(typ: String, filename: String) = {
|
||||
System.out.println("The following " + typ + " called " + filename +
|
||||
(if (deleteFile(filename)) " was deleted." else " could not be deleted."))
|
||||
}
|
||||
test("file", "input.txt")
|
||||
test("file", File.separatorChar + "input.txt")
|
||||
test("directory", "docs")
|
||||
test("directory", File.separatorChar + "docs" + File.separatorChar)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue