@Override
	public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
		final String filePath = chunkContext.getStepContext().getStepExecution().getExecutionContext().getString(
				"filePath");
		Assert.notNull(filePath);
		if (logger.isDebugEnabled()) {
			logger.debug("Transferring " + filePath + " to HDFS");
		}
		boolean result = this.template.get(filePath, new InputStreamCallback() {

			@Override
			public void doWithInputStream(InputStream stream) throws IOException {
				OutputStreamWriter writer = new OutputStreamWriter(configuration,
						new Path(hdfsDirectory + filePath), null);
				byte[] buff = new byte[1024];
				int len;
				while ((len = stream.read(buff)) > 0) {
					if (len == buff.length) {
						writer.write(buff);
					}
					else {
						writer.write(Arrays.copyOf(buff, len));
					}
				}
				writer.close();
			}

		});
		if (!result) {
			throw new MessagingException("Error during file transfer");
		}
		else {
			if (logger.isDebugEnabled()) {
				logger.debug("Transferred " + filePath + " to HDFS");
			}
			return RepeatStatus.FINISHED;
		}
	}
Retrieves a fileName from the step execution context; uses the {@link RemoteFileTemplate} to retrieve the file as a
String and writes to hdfs.

@author Gary Russell
extensions/spring-xd-extension-batch/src/main/java/org/springframework/batch/integration/x/RemoteFileToHadoopTasklet.java