I have String s = "three_v1_FVID121007.jpg".
How can I check if this file exists in the C:\
directory or subdirectories?
I have String s = "three_v1_FVID121007.jpg".
How can I check if this file exists in the C:\
directory or subdirectories?
File file = new File("three_v1_FVID121007.jpg");
if(file.exists()){
System.out.println("file is already there");
}else{
System.out.println("Not find file ");
}
With apache commons-io FileUtils
:
FileUtils.listFiles(
new File("C:\\"), // base dir
new NameFileFilter("three_v1_FVID121007.jpg"), // file filter
TrueFileFilter.INSTANCE // directory filter
).size() == 1;
(not tested)