Zizalik

CurrencyMainJSON

May 16th, 2018
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package kontrolltoo;
  7.  
  8. import DB.Database;
  9. import XML.Continent;
  10. import XML.Continents;
  11. import XML.CurrencyXML;
  12. import java.io.File;
  13. import java.io.IOException;
  14. import java.util.ArrayList;
  15. import java.util.List;
  16. import java.util.Set;
  17. import javax.xml.bind.JAXBContext;
  18. import javax.xml.bind.JAXBException;
  19. import javax.xml.bind.Marshaller;
  20.  
  21.  
  22. public class Kontrolltoo {
  23. // public static List<Currency> andmed =JSONData.data;
  24.  
  25. public static Set<CurrencyXML> currEu =CurrencyData.currEu;
  26. public static Set<CurrencyXML> currAsia =CurrencyData.currAsia;
  27. public static Set<CurrencyXML> currUSA =CurrencyData.currUSA;
  28.  
  29. /**
  30. * @param args the command line arguments
  31. */
  32. public static void main(String[] args) throws IOException, JAXBException {
  33. // TODO code application logic here
  34.  
  35. //DB
  36. Database.main(args);
  37.  
  38. //XML
  39. //continentidesse currency lisamine.
  40. List<Continent> continents = new ArrayList<>();
  41. Continent continent1 = new Continent("Europe",currEu);
  42. Continent continent2 = new Continent("Asia",currAsia);
  43. Continent continent3 = new Continent("North America",currUSA);
  44.  
  45. //info lisamine listi
  46. continents.add(continent1);
  47.  
  48. JAXBContext context = JAXBContext.newInstance(Continents.class);
  49.  
  50. //XML faili loomine loodud andmetega
  51. Continents toXml = new Continents();
  52. toXml.setContinents(continents);
  53. Marshaller marshaller = context.createMarshaller();
  54. marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
  55. marshaller.marshal(toXml, new File("CurrencyXML.xml"));
  56. }
  57.  
  58. }
Add Comment
Please, Sign In to add comment