public final class Files
extends java.lang.Object
File
s.Modifier and Type | Method and Description |
---|---|
static java.io.File |
findNextFile(java.io.File directory,
java.lang.String filenameFormat)
Returns a
File that denotes a file that does not currently exist. |
public static java.io.File findNextFile(java.io.File directory, java.lang.String filenameFormat)
File
that denotes a file that does not currently exist.
The filename of the file is based on filenameFormat
and a number that is calculated by this method. For this algorithm to work, filenameFormat
needs to have exactly one occurrence of "%s"
in it.
An example of filenameFormat
could be "Dayflower-Image-%s.png"
. This could result in a filename of "Dayflower-Image-1.png"
. If a file with that filename already exists, the next would be "Dayflower-Image-2.png"
.
If either directory
or filenameFormat
are null
, a NullPointerException
will be thrown.
directory
- the directory of the filesfilenameFormat
- the filename format to useFile
that denotes a file that does not currently exist