How to save RDD data into json files, not folders

后端 未结 3 1070
挽巷
挽巷 2020-12-07 04:46

I am receiving the streaming data myDStream (DStream[String]) that I want to save in S3 (basically, for this question, it doesn\'t matter where exa

3条回答
  •  情歌与酒
    2020-12-07 05:32

    For JAVA I implemented this one. Hope it helps:

        val fs = FileSystem.get(spark.sparkContext().hadoopConfiguration());
        File dir = new File(System.getProperty("user.dir") + "/my.csv/");
        File[] files = dir.listFiles((d, name) -> name.endsWith(".csv"));
        fs.rename(new Path(files[0].toURI()), new Path(System.getProperty("user.dir") + "/csvDirectory/newData.csv"));
        fs.delete(new Path(System.getProperty("user.dir") + "/my.csv/"), true);
    

提交回复
热议问题