是你可以定義使用Spring Batch。 您讀者的物品可以是File
。
public class CustomItemReader implements InitializingBean{
private List<File> yourFiles= null;
public File read() {
if ((yourFiles!= null) && (yourFiles.size() != 0)) {
return yourFiles.remove(0);
}
return null;
}
//Reading Items from Service
private void reloadItems() {
this.yourItems= new ArrayList<File>();
// populate the items
}
@Override
public void afterPropertiesSet() throws Exception {
reloadItems();
}
}
定製處理器:
public class MyProcessor implements ItemProcessor<File, File> {
@Override
public File process(File arg0) throws Exception {
// Apply any logic to your File before transferring it to the writer
return arg0;
}
}
和一個自定義作家:
public class MyWriter{
public void write(File file) throws IOException {
}
}