import java.io.File
import org.apache.spark.SparkContext
object IntegrateUtils {
def judgePath(sc: SparkContext, path: String): Unit = {
// 1 获取文件系统
val filePath = new org.apache.hadoop.fs.Path(path)
val fileSystem = filePath.getFileSystem(sc.hadoopConfiguration)
// 2 判断路径存在时, 则删除
if (fileSystem.exists(filePath)) {
println("filePath is exists, delete: " + filePath)
fileSystem.delete(filePath, true)
} else {
println("filePath doesn't exists, create: " + filePath)
}
fileSystem.mkdirs(filePath)
}
}
03-24
2530
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交