title: Reading a text file from HDFS in Scala/Spark
body: <p>I am using Scala and Spark and want to read in an XML file as a single string.
  I'm struggling to find a neat Scala-ish way to do this.</p>
  
  <p>My first thought was to use</p>
  
  <pre><code>val fileContents: RDD[String] = sparkContext.textfile(pathToFile)
  val combinedContents: String = fileContents.reduce((line1, line2) =&gt; line1 + line2)
  </code></pre>
  
  <p>But I am concerned about this maintaining the order of lines that is important to keep the integrity of the xml contained within the string.</p>
  
  <p>Other stuff I have found online to read files in HDFS involve using deprecated methods so I want to avoid those. Any ideas?</p>