title: hadoop check if the path is valid and create if not
body: <p>I have a simple MR job that needs to create a directory in hdfs based on the timestamp. I am having hard time finding the correct api (in hadoop 2.0.3 to find the status and create a directory if it doesn't exist). Can some one suggest the right way of doing it? here is the existing code:</p>
  
  <pre><code>FileSystem fileSystem = FileSystem.get(new Configuration());
  Calendar c = Calendar.getInstance();
  String basepath = "/dev/group/data/json/";
  for ( Record record: records){
      c.setTimeInMillis(record.timestamp );
      Path path = new Path(basepath + c.get(Calendar.YEAR) + "/" + c.get(Calendar.MONTH));
      // Check if the path is valid and create hdfs folder if not
      FileStatus[] status = filesystem.???
      context.write(key, new Text(mapper.writeValueAsString(record)));            
  }
  </code></pre>
  
  <p>Thx</p>