@Override
  public void saveField(Type type, String id, String key, String val)
    throws NotFoundException {
    if (val == null) {
      return;
    }
    PrintWriter out = null;
    //todo: FileSystem#setPermission() - should this make sure to set 777 on jobs/ ?
    Path keyfile= new Path(getPath(type) + "/" + id + "/" + key); 
    try {
      // This will replace the old value if there is one
      // Overwrite the existing file
      out = new PrintWriter(new OutputStreamWriter(fs.create(keyfile)));
      out.write(val);
      out.flush();
    } catch (Exception e) {
      String errMsg = "Couldn't write to " + keyfile + ": " + e.getMessage();
      LOG.error(errMsg, e);
      throw new NotFoundException(errMsg, e);
    } finally {
      close(out);
    }
  }
HDFS implementation of templeton storage.

 This implementation assumes that all keys in key/value pairs are
 chosen such that they don't have any newlines in them.
hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/tool/HDFSStorage.java