Java – FileAlreadyExistsException
FileAlreadyExistsException: Thrown when an attempt is made to create a file that already exists.
Example:
import java.nio.file.*;
import java.io.IOException;
try {
Path path = Paths.get("existingFile.txt");
Files.createFile(path);
} catch (FileAlreadyExistsException e) {
System.out.println("Caught FileAlreadyExistsException: " + e.getMessage());
}
No images available.