Esempio n. 1
0
 public void commit(Document doc) throws Exception {
   try {
     writeToXml(fileName, doc);
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
Esempio n. 2
0
 public void rollback(Document doc) {
   try {
     writeToXml(fileName, doc);
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
Esempio n. 3
0
  public Document getDocument() {
    Document doc = null;
    try {
      DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
      DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
      File f = new File(fileName);

      if (f.exists()) {
        doc = docBuilder.parse(fileName);
      } else {
        doc = docBuilder.newDocument();
        Element rootElement = doc.createElement("root");
        doc.appendChild(rootElement);

        writeToXml(fileName, doc);
        System.out.println("New XML file created!");
      }
    } catch (Exception e) {
      System.out.println("EEEERRRRRR");
      e.printStackTrace();
    }

    return doc;
  }