Program.java 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import java.util.ArrayList;
  2. public class Program {
  3. public static void main(String[] args) {
  4. Studentsreader sr = new Studentsreader();
  5. Classroom classroom = null;
  6. try {
  7. classroom = sr.read("students.csv");
  8. } catch(IllegalCSVStructureException e) {
  9. System.out.println(e.getMessage());
  10. System.exit(-1);
  11. }
  12. // nice prints
  13. System.out.println("current classroom (as read by Studentsreader)\n");
  14. System.out.println(classroom.toCSVString());
  15. // start writin our nifty lil xml
  16. Nodeswriter nw = new Nodeswriter();
  17. nw.write("students.xml", classroom);
  18. // start readin our nifty lil xml
  19. Nodesreader nr = new Nodesreader();
  20. Classroom output = nr.read("students.xml");
  21. // some more nice prints
  22. System.out.println("output classroom (as read by Nodesreader)\n");
  23. System.out.println(output.toCSVString());
  24. // and convert once again (for testing purposes)
  25. nw.write("students2.xml", output);
  26. // interestingly, for my piece of testdata, reading the output file and writing it again
  27. // rearranges the order of the optional subjects
  28. // their values remain correct though
  29. }
  30. }