I'm doing rdd.saveAsTextFiles(path), but sometimes, it will report error:
py4j.protocol.Py4JJavaError: An error occurred while calling o41.saveAsTextFile.
: org.apache.hadoop.mapred.FileAlreadyExistsException: Output directory file:/D:/code/use_spark/output already exists or hdfs://user/output exists
Every time I need remove existed file/folder mannally, it is not really smart.
Is there a way to delete the file/folder in hdfs/local by using pyspark API. Dont use command line in code.