Does this mean you're not sure how to to create a File (or FileWriter) object if you have the file name as a string?
Well I have tried this as well:
File file = fc.getSelectedFile();
String fileName = file.getName();
String newFile = fileName + ".txt";
try{
boolean isFile = false;
if(!file.exists())
isFile = file.createNewFile(); // returns true which means file
// should have been created.
FileWriter outFile = new FileWriter(file);
PrintWriter out = new PrintWriter(outFile,true);
out.println("data");
out.close();
}
catch(IOException e) {}
But still the file is not saved as desired when user enters file name without explicitly specifying the extn.
