tags:

views:

231

answers:

1

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  A: 

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....
}
Mork0075
+1, this approach would work fine.
Jim Ferrans