Java - find next file in sequence
<p>I have a directory with a number of images. Each image is in the format image-xxx.png, where xxx is a random integer (between 0 and 1million). Not all numbers are taken, so for instance it is possible to have image-1.png followed by image-27.png, etc (they're not 0 padded). Let's say I have the following files in my directory:</p>

<pre><code>image-1.png
image-27.png
image-1511.png
image-125252.png
</code></pre>

<p>How can I find the next integer after 27 (1511) without looping through each possible integer between 28 to 1511 and checking if file.exists()?</p>
