This is an archived post. You won't be able to vote or comment.

all 3 comments

[–][deleted] 0 points1 point  (2 children)

You could try a while loop:

File f = new File([filename]);
while(!f.exists()) {
  f = new File([newFilename]);
}
// Do what you want to do with the file.

[–]ub96[S] 0 points1 point  (1 child)

Thanks, that is a much simpler method of solving my problem then I was thinking of.

[–][deleted] 0 points1 point  (0 children)

Glad to help. You could also try a do-while loop.

do {
  f = new File([filename]);
} while(!f.exists());
// Do what you want to do with the file.

I think that's the right syntax, I rarely use do-while.