-3
Hello I have a list of Notes objects and need to save them in xml files. I am trying to convert this list to arrays to add them to the xml file. However I am not able to do the conversion correctly, as it is a list of Notes that receive another list of Products. What’s best to fix this?
List<Notas> listaNotas;
Notas[] arrayListaNotas;
for(int i=0; i<listaNotas.size();i++) {
arrayListaNotas =
listaNotas.get(i).getProdutos().toArray(new
Notas[listaNotas.get(i).getProdutos().size()]);
listaInsercaoXml[i] =arrayListaNotas;// Aqui acontece o erro na hora de tentar atribuir
}
int qtdeNotasXml=5;
for(int i=0; i<listaInsercaoXml.length;i++) {
stringXml = xstream.toXML(Arrays.copyOfRange(listaInsercaoXml, i, Math.min(listaInsercaoXml.length, i+qtdeNotasXml)));
file = new PrintWriter(new BufferedWriter(new FileWriter("C:\\notas"+i+".xml")));
file.println(stringXml);
file.close();
}
to generate the xml I am using the Xstream API. I also already have a java object for notes that receives a list of product objects (I already have). But when I try to convert to array, I can’t recover the list of Products that each note has.
– Diego