How do I check if a file exists in Java? September 6, 2022 by Tarik Using java.io.File: File f = new File(filePathString); if(f.exists() && !f.isDirectory()) { // do something }