0

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

1 Answer 1

1

Build a special structure with a list property, read the input into this list and serialize this 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....
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.