So I'm trying to create an XML File in my C:\ directory and every time I launch the program, it says Access Is Denied. The following is my code:
public void buildXML(){
try {
DocumentBuilderFactory xmlFac = DocumentBuilderFactory.newInstance();
DocumentBuilder doc = xmlFac.newDocumentBuilder();
Document settings = doc.newDocument();
Element rootElement = settings.createElement("AppSettings");
rootElement.appendChild(settings.createElement("FAK0"));
TransformerFactory transform = TransformerFactory.newInstance();
Transformer former = transform.newTransformer();
DOMSource src = new DOMSource(settings);
StreamResult res = new StreamResult(new File("C:\\file.xml"));
former.transform(src, res);
}catch(Exception e){
System.out.println(e+"");
}
}
And here is the output on the console:
javax.xml.transform.TransformerException: java.io.FileNotFoundException: C:\file.xml (Access is denied)
Is it because I have no administrator access or what? If it is then that would be very unsettling.
C:? On any other partition it should work.