code: public static FSDataOutputStream tryCreateFile(FileSystem fs, Path file) throws IOException {
      try {
        FSDataOutputStream os = fs.create(file, false);
        return os;
      } catch (FileAlreadyExistsException e) {
        return null;
      } catch (RemoteException e) {
        if( e.unwrapRemoteException() instanceof AlreadyBeingCreatedException ) {
          return null;
        } else { // unexpected error
          throw e;
        }
      }
    }
docs: Returns null if file already exists. throws if there was unexpected problem