I am trying to read a remote file line by line, using spring integration. Using the spring documentation found here I have set up my project to poll for the file and transfer it
You can use after the receiving File and to delimit the content of payload to the list of lines.
UPDATE
I would like to retrieve one line at a time from the remote file, then process the contents of that line, then retrieve the next line. Similar to creating a java.io.inputstream for a local file and reading it line by line.
Well, Unfortunatelly we don't provide high-level component for that, but you can try to use the features from the RemoteFileTemplate:
RemoteFileTemplate template = new RemoteFileTemplate(this.ftpSessionFactory);
template.setFileNameExpression(new SpelExpressionParser().parseExpression("payload"));
template.setBeanFactory(mock(BeanFactory.class));
template.afterPropertiesSet();
final ByteArrayOutputStream baos1 = new ByteArrayOutputStream();
template.get(new GenericMessage("ftpSource/ftpSource1.txt"), new InputStreamCallback() {
@Override
public void doWithInputStream(InputStream stream) throws IOException {
FileCopyUtils.copy(stream, baos1);
}
});
This code you can to some your POJO service and wire the last one with .