When I try to save a file with the file name that already exists, I need to prompt the user to rename the file in order to save. What is the better way to prompt the user rename the File f the same File exists in the directory?I need to implement this via the same dialog box I use to save the file.
File exportFile = new File(FilePath + "\\"+ FileName);
boolean exists = exportFile.exists();
if (!exists) {
System.out.println("File does not exists");
// TODO code here
}
else{
System.out.println( "File exists.");
// TODO code here
}
The code is to be implemented in the //TODO part. How can I do this?
while(exists) { \\Prompt the user to enter another name & change "exists" status correspondingly}where dis is a DataInputStream object. Good luck.