public static boolean createDataFileOnRemote(String privateKey, String host, String dir, String fileName,
			String payload, int retryTime)
	{
		Assert.hasText(privateKey, "privateKey must not be empty nor null.");
		Assert.hasText(host, "The remote machine's URL must be specified.");
		Assert.notNull(dir, "dir should not be null");
		Assert.hasText(fileName, "The remote file name must be specified.");
		boolean isFileCopied = false;
		long timeout = System.currentTimeMillis() + retryTime;
		while (!isFileCopied && System.currentTimeMillis() < timeout) {
			SshjSshClient client = getSSHClient(host, privateKey);
			client.exec("mkdir -p " + dir);
			ExecResponse response = client.exec("ls -al " + dir );
			if (response.getExitStatus() > 0) {
				continue; //directory was not created
			}
			client.put(dir + "/" + fileName, payload);
			response = client.exec("ls -al " + dir + "/" + fileName);
			if (response.getExitStatus() > 0) {
				continue; //file was not created
			}
			response = client.exec("cat " + dir + "/" + fileName);
			if (response.getExitStatus() > 0 || !payload.equals(response.getOutput())) {
				continue;//data stored on machine is different than was expected.
			}
			isFileCopied = true;
		}
		return isFileCopied;
	}
Creates a file on a remote EC2 machine with the payload as its contents.

@param privateKey The ssh private key for the remote container
@param host The remote machine's ip.
@param dir The directory to write the file
@param fileName The fully qualified file name of the file to be created.
@param payload the data to write to the file
@param retryTime the time in millis to retry to push data file to remote system.
spring-xd-integration-test/src/main/java/org/springframework/xd/integration/util/StreamUtils.java