public static Promise<Void> writeNewFile(Executor executor, Path path, ByteBuf buf) {
		return openAsync(executor, path, set(WRITE, CREATE_NEW))
				.then(file -> file.write(buf)
						.then($ -> file.close()))
				.whenException($ -> buf.recycle());
	}
public static Promise < Void > writeNewFile ( Executor executor , Path path , ByteBuf buf ) { return openAsync ( executor , path , set ( WRITE , CREATE_NEW ) ) . then ( file -> file . write ( buf ) . then ( $ -> file . close ( ) ) ) . whenException ( $ -> buf . recycle ( ) ) ; }
Creates new file and writes a sequence of bytes to this file from
the given buffer, starting at the given file position.
If file already exists, promise fails with exception.

@param path the path of the file to create and write
@param buf  the buffer from which bytes are to be transferred byteBuffer