Reputation: 75
How do I set path for this created file? The user should specify the path in his arguments. Currently this code is able to create a file. The user needs to store this file wherever he wants. I am doing this in Netbeans.
File file = new File("Export.xml");
System.out.println(file.getName());
System.out.println(file.getAbsolutePath());
BufferedWriter bw = new BufferedWriter
(new OutputStreamWriter(new FileOutputStream(file)));
Upvotes: 0
Views: 91
Reputation: 68942
Simply append your filename to the path.
public void export(String path) {
File file = new File( path + File.separator + "Export.xml" );
...
}
public void caller() {
export("C:\\temp" );
}
Upvotes: 2