public void commit(Document doc) throws Exception { try { writeToXml(fileName, doc); } catch (Exception e) { e.printStackTrace(); } }
public void rollback(Document doc) { try { writeToXml(fileName, doc); } catch (Exception e) { e.printStackTrace(); } }
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; }