Spark & Scala

[ Spark & Scala ] File, Folder 삭제

구티맨 2020. 4. 6. 08:25
import org.apache.hadoop.fs.{FileSystem, Path}

val fs = FileSystem.get(sc.hadoopConfiguration)

val outPutPath = new Path("/path/to/folder")

if (fs.exists(outPutPath))
  fs.delete(outPutPath, true)

FileSystem 을 사용하여 파일 또는 폴더를 삭제 할 수 있다.