Try_Catch

"Java Stuty"

Posted by Chungman on March 24, 2021

Try_Catch 예제

ExceptionMain04

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package Java0324.Lecture13.Exception;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

public class ExceptionMain04 {			// 2중 try-catch

	public static void main(String[] args) {
		
		
		try {
			FileReader fr = new FileReader("a.txt");	// checked exception
		} catch(FileNotFoundException fnfe) {
			try {
				FileWriter fw = new FileWriter("error.log");
			} catch (IOException e) {
				e.printStackTrace();
			}
			
		}
		
	}

}