I am trying to creating an XML file using java. I am explicitly passing the path for the new XML file to be created and it is getting created successfully. But now, how do I get the XML file in the project folder automatically without giving the path.
My CWD is - C:\Users\sit\eclipse-workspace\XMLProject\src
try {
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
Document doc = docBuilder.newDocument();
TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();
DOMSource source = new DOMSource(doc);
StreamResult result = new StreamResult(new File("C:\Users\sit\eclipse-workspace\XMLProject\src\abc.xml"));
transformer.transform(source, result);
} catch (ParserConfigurationException pce) {
pce.printStackTrace();
} catch (TransformerException tfe) {
tfe.printStackTrace();
}
}
}