@NonNull
    public static File getUniqueNamedFile(final File file) {
        if (!file.exists()) {
            return file;
        }
        final String baseNameAndPath = file.getPath();
        final String prefix = StringUtils.substringBeforeLast(baseNameAndPath, ".") + "_";
        final String extension = "." + StringUtils.substringAfterLast(baseNameAndPath, ".");
        for (int i = 2; i < Integer.MAX_VALUE; i++) {
            final File numbered = new File(prefix + i + extension);
            if (!numbered.exists()) {
                return numbered;
            }
        }
        throw new IllegalStateException("Unable to generate a non-existing file name");
    }
Create a unique non existing file named like the given file name. If a file with the given name already exists,
add a number as suffix to the file name.<br>
Example: For the file name "file.ext" this will return the first file of the list
<ul>
<li>file.ext</li>
<li>file_2.ext</li>
<li>file_3.ext</li>
</ul>
which does not yet exist.
main/src/main/java/cgeo/geocaching/utils/FileUtils.java