/** file system API */import org.apache.hadoop.fs.{FileSystem, Path}import org.apache.hadoop.conf.Configuration
val conf =newConfiguration()
val path =newPath(dir)
val fs: FileSystem = FileSystem.get(path.toUri, conf)if(fs.exists(path)){colorful_green_println(path.toString +" exists and delete.")
fs.delete(path)}
2. CommendLine
import org.apache.commons.cli.{BasicParser, CommandLine, Options}/** Parse the arguments */
val options: Options =newOptions()
options.addOption("yesterday",true,"The date of yesterday.")
options.addOption("window",true,"The window of data we used.")
options.addOption("base_dir",true,"The base dir of path")
val parser: BasicParser =newBasicParser()
val cl: CommandLine = parser.parse(options, args)
val yesterday = cl.getOptionValue("yesterday")
val window = cl.getOptionValue("window").toInt
val base_dir = cl.getOptionValue("base_dir")