title: FileUtil.copyMerge() in AWS S3
body: <p>I have Loaded a <code>DataFrame</code> into <code>HDFS</code> as <code>text</code> format using below code. <code>finalDataFrame</code> is the <code>DataFrame</code></p>
  
  <pre><code>finalDataFrame.repartition(1).rdd.saveAsTextFile(targetFile)
  </code></pre>
  
  <p>After executing the above code I found that a directory created with the file name I provided and under the directory a file created but not in text format. The file name is like <strong>part-00000</strong>.</p>
  
  <p>I have resolved this in <code>HDFS</code> using below code.</p>
  
  <pre><code>val hadoopConfig = new Configuration()
  val hdfs = FileSystem.get(hadoopConfig)
  FileUtil.copyMerge(hdfs, new Path(srcPath), hdfs, new Path(dstPath), true, hadoopConfig, null)
  </code></pre>
  
  <p>Now I can get the text file in the mentioned path with given file name.</p>
  
  <p>But when I am trying to do the same operation in S3 it is showing some exception</p>
  
  <pre><code>FileUtil.copyMerge(hdfs, new Path(srcPath), hdfs, new Path(dstPath), true, hadoopConfig, null)
  
  java.lang.IllegalArgumentException: Wrong FS:
  s3a://globalhadoop/data, expected:
  hdfs://*********.aws.*****.com:8050
  </code></pre>
  
  <p>It seems that S3 path is not supporting over here. Can anyone please assist how to do this.</p>