title: HDFS from Java - Specifying the User
body: <p>I'm happily connecting to HDFS and listing my home directory:</p>
  
  <pre><code>Configuration conf = new Configuration();
  conf.set("fs.defaultFS", "hdfs://hadoop:8020");
  conf.set("fs.hdfs.impl", "org.apache.hadoop.hdfs.DistributedFileSystem");
  FileSystem fs = FileSystem.get(conf);
  RemoteIterator&lt;LocatedFileStatus&gt; ri = fs.listFiles(fs.getHomeDirectory(), false);
  while (ri.hasNext()) {
      LocatedFileStatus lfs = ri.next();
      log.debug(lfs.getPath().toString());
  }
  fs.close();
  </code></pre>
  
  <p>What I'm wanting to do now though is connect as a specific user (not the whois user). Does anyone know how you specify which user you connect as?</p>