title: How to write twitter tweets to HDFS using Spark Streaming Java API
body: <pre><code>SparkConf conf = new SparkConf().setMaster("local[2]").setAppName("SparkTwitterHelloWorldExample");
  JavaStreamingContext jssc = new JavaStreamingContext(conf, new Duration(60000));
  System.setProperty("twitter4j.oauth.consumerKey", consumerKey);
  System.setProperty("twitter4j.oauth.consumerSecret", consumerSecret);
  System.setProperty("twitter4j.oauth.accessToken", accessToken);
  System.setProperty("twitter4j.oauth.accessTokenSecret", accessTokenSecret);
  String[] filters = new String[] {"Narendra Modi"};
  JavaReceiverInputDStream&lt;Status&gt; twitterStream = TwitterUtils.createStream(jssc,filters);
  
  // Without filter: Output text of all tweets
  JavaDStream&lt;String&gt; statuses = twitterStream.map(
          new Function&lt;Status, String&gt;() {
              public String call(Status status) { return status.getText(); }
          }
  );
  statuses.print();
  statuses.saveAsHadoopFiles("hdfs://HadoopSystem-150s:8020/Spark_Twitter_out","txt");
  </code></pre>
  
  <p>I am able to fetch the Twitter tweets but I am getting error while writing to HDFS.</p>
  
  <p>Can some one help me in saving the tweets to HDFS using Java</p>
  
  <p>Here is the Error I am getting:</p>
  
  <blockquote>
    <p>[ERROR] Failed to execute goal
    org.apache.maven.plugins:maven-compiler-plugin:3.1:compile
    (default-compile) on project SparkTwitterHelloWorldExample:
    Compilation failure [ERROR]
    /home/Hadoop/Mani/SparkTwitterHelloWorldExample-master/src/main/java/de/michaelgoettsche/SparkTwitterHelloWorldExample.java:[58,17]
    cannot find symbol [ERROR] symbol  : method
    saveAsHadoopFiles(java.lang.String,java.lang.String) [ERROR] location:
    class
    org.apache.spark.streaming.api.java.JavaDStream</p>
  </blockquote>