Is there a way in Java to create a file and rename it if that file already exists, e.g. “Dog.jpg”, to something like that “Dog(1).jpg” and so on (“Dog(2).jpg” if “Dog(1).jpg” exists too, etc.)?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Fileclass in java has a method calledexistsuse that to check if the file exists or notIf it does exist rename it to something else.
Repeat this process until you find a file name that does not exsist