How to store multiple inputs in XML file using XStream

I want to write a program for this: in a folder I have n number of files; first read one file and do some operation, then save the result in a separate XML file and the second read file will perform the operation again and save the result in the same XML file, even the same procedure for n number of files. The program reads all files one by one and saves the results of each file in one xml file using X-Stream. Please provide examples of how I will do this. Thanks.

0


a source to share


1 answer


Create a custom structure with a list property, read the input to that list, and serialize that list at the end.



public class MyEntityList{
  public List<MyEntity> list;
}

public static void main(..){
   MyEntityList myEntityList ...

   foreach file in directory..
      MyEntity m = deserialize xml from file
      myEntitiyList.list.add(m);

   myEntityList.serializeToXml....
}

      

+1


a source







All Articles