Could you kindly help me please ? I am trying to delete a specific file in Scala, however all the possibilities that I have tried did not seem to work out. For example :
new File(filePath).delete()
new File(filePath).deleteOnExit()
I don’t see anything wrong with the code. Are you sure filePath is pointing where you think it is? I created directory /tmp/foo. Touched file /tmp/foo/xyz. Then ran this code after which file xyz was deleted.
package foo
import java.io._
object Test {
def main(av: Array[String]): Unit =
new File("/tmp/foo/xyz").delete()
}