how do i write a program in java that i should get file path from arguments.currently this code creates the file at d:\ but i need to get this file name as a argument how do i do it???am using netbeans for this.
StringWriter sw = new StringWriter(); StreamResult result = new StreamResult(sw); DOMSource source = new DOMSource(doc); transformer.transform(source, result); String xmlString = sw.toString(); File file = new File("d:/Exported.xml"); BufferedWriter bw = new BufferedWriter (new OutputStreamWriter(new FileOutputStream(file))); bw.write(xmlString); bw.flush(); bw.close();
Use file.getName() method of File class.
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.