title: Write a file in hdfs with Java
body: <p>I want to create a file in HDFS and write data in that. I used this code:</p>
  
  <pre><code>Configuration config = new Configuration();     
  FileSystem fs = FileSystem.get(config); 
  Path filenamePath = new Path("input.txt");  
  try {
      if (fs.exists(filenamePath)) {
          fs.delete(filenamePath, true);
      }
  
      FSDataOutputStream fin = fs.create(filenamePath);
      fin.writeUTF("hello");
      fin.close();
  }
  </code></pre>
  
  <p>It creates the file, but it does't write anything in it. I searched a lot but 
  didn't find anything. What is my problem? Do I need any permission to write in HDFS?</p>
  
  <p>Thanks. </p>