Well, finally, the solution came out, Iβm not very excited, but it works, and I donβt have much time, so I expanded MultiResourceItemWriter and redefined the βwriteβ method, processing the map elements and writing the files myself. In case someone needs it, here it is.
@Override public void write(List items) throws Exception { for (Object o : items) { //do some processing here writeFile(anotherObject); } private void writeFile (AnotherObject anotherObject) throws IOException { File file = new File("name.xml"); boolean restarted = file.exists(); FileUtils.setUpOutputFile(file, restarted, true, true); StringBuffer sb = new StringBuffer(); sb.append(xStream.toXML(anotherObject)); FileOutputStream os = new FileOutputStream(file, true); BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(os, Charset.forName("UTF-8"))); bufferedWriter.write(sb.toString()); bufferedWriter.close(); }
And what is it, I want to believe that there is a better option that I do not know, but at the moment this is my decision. If anyone knows how I can improve my implementation, I would like to know.
source share