code: public static FSDataOutputStream create(FileSystem fs,
        Path file, FsPermission permission) throws IOException {
      // create the file with default permission
      FSDataOutputStream out = fs.create(file);
      // set its permission to the supplied one
      fs.setPermission(file, permission);
      return out;
    }
docs: create a file with the provided permission
  The permission of the file is set to be the provided permission as in
  setPermission, not permission&~umask
  
  It is implemented using two RPCs. It is understood that it is inefficient,
  but the implementation is thread-safe. The other option is to change the
  value of umask in configuration to be 0, but it is not thread-safe.
  
  @param fs file system handle
  @param file the name of the file to be created
  @param permission the permission of the file
  @return an output stream
  @throws IOException