JAVA/예제
[JAVA] ch08-13. 예외 처리 13
밍글링글링
2017. 8. 22. 11:53
728x90
public class Ex13 {
public static void main(String[] args) {
try{//Exception이 발생하면 실행이 안될 수도 있다.
startInstall();
copyFiles();
}catch(Exception e){//Exception이 발생하지 않으면 실행이 안될 수도 있다.
e.printStackTrace();
}finally{ //반드시 실행시키고 싶은 명령이 있을 때 finally를 쓴다. 쓰는 순서는 try catch catch ..... finally 순으로.
deleteTempFiles();
}
}
static void startInstall(){}
static void copyFiles(){}
static void deleteTempFiles(){} //파일 설치할 때 성공하든 안하든 임시파일은 무조건 삭제해야하므로 finally에 쓴다.
}
728x90