How to access HDFS file system in Apache Spark

  • The following segment accesses the file inputdata.txt stored in HDFSCode Segment

    SparkConf conf = new SparkConf().setAppName("Sample");
    JavaSparkContext sc = new JavaSparkContext(conf);
    JavaRDD file =sc.textFile("hdfs://localhost:54310/inputdata.txt");