I wrote the below code inorder to write an xml output to a file in my Tomcat Server. When I ran the code I get the below error. May I know what is wrong in my code. Thanks in advance. It is supposed to create a directory with name test and then the file test.xml in the path I specified in my server. But, it is not doing doing that and instead it is looking for that path in my local machine
java.io.FileNotFounException: C:\test\test.xml The system cannot find the path specified
// write the content into xml file
TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();
DOMSource source = new DOMSource(doc);
StreamResult result = new StreamResult(new File("/test/test.xml"));
transformer.transform(source, result);
// Output to console for testing
StreamResult consoleResult = new StreamResult(System.out);
transformer.transform(source, consoleResult);