Reputation: 3031
Because I asked wrong question last time, I want to correct my intention. How can I find file by name in specified folder? I have a variable with a name of this file and i want to find it in specified folder. Any ideas?
Upvotes: 1
Views: 476
Reputation: 5653
Maybe the simplest thing that works is:
String dirPath = "path/to/directory";
String fileName = "foo.txt";
boolean fileExistsInDir = new File( dirPath, fileName ).exists();
File is just a placeholder for a location in the file system. The location does not have to exist.
Upvotes: 5
Reputation: 6730
Use Finding files in Java as a starting point. It should have everything that you are looking for - ask another specific question if you get stuck.
Upvotes: 2