Writing to a file in Apache Spark
<p>I am writing a Scala code that requires me to write to a file in HDFS.
When I use <code>Filewriter.write</code> on local, it works. The same thing does not work on HDFS. 
Upon checking, I found that there are the following options to write in Apache Spark- 
<code>RDD.saveAsTextFile</code> and <code>DataFrame.write.format</code>.</p>

<p>My question is: what if I just want to write an int or string to a file in Apache Spark?</p>

<p>Follow up:
I need to write to an output file a header, DataFrame contents and then append some string.
Does <code>sc.parallelize(Seq(&lt;String&gt;))</code> help?</p>