title: Merging files in hdfs using java program
body: <p>I am new to big data and was working on a small task where i need to merge multiple files into a single file in hdfs. I was using Java program to accomplish this(merging all files similar to prod* into a single prod.txt file). I had searched for help and the code i have written so far is:</p>
  
  <p>public class MergeFiles {</p>
  
  <pre><code>public static void main(String[] args) throws FileNotFoundException {
      // TODO Auto-generated method stub
  
      String srcPath = "/user/demouser/first/prod*"; 
      String dstPath = "/user/demouser/second/prod.txt"; 
      Configuration conf = new Configuration(); 
      conf.set("fs.default.name","http://hostname:portnumber/");
      try 
      { 
          FileSystem hdfs = FileSystem.get(conf); 
          FileUtil.copyMerge(hdfs, new Path(srcPath), hdfs, new Path(dstPath), false, conf, null); 
          } 
      catch (IOException e) 
      { }
  
      }
  </code></pre>
  
  <p>}</p>
  
  <p>It is not working and i am not able to figure out how to resolve this. I also did not understand the working of "fs.default.name". Please help.</p>