memostack
article thumbnail
Java 파일 존재 여부, 파일 또는 디렉토리 확인하기
Language/JAVA 2020. 10. 17. 18:28

파일이 존재하는지 확인 Java에서 파일이 존재하는지 확인하기 위해서는 File 오브젝트의 exists() 메소드를 사용한다. import java.io.File; public class App { public static void main( String[] args ) { // 파일의 경로 final File driverFile = new File("src/resources/bin/chromedriver.exe"); final String driverFilePath = driverFile.getAbsolutePath(); // 파일이 존재하는지 확인 if(!driverFile.exists()) { // 파일이 존재하지 않는다면, 오류 발생. throw new RuntimeException("Not fo..