"보고되지 않은 예외 ioexception; 오류가 계속 발생하거나 보관해야하거나 throw되어야한다고 선언했습니다." 제공된 경로 또는 try-catch 블록의 오류입니다."보고되지 않은 예외 ioexception이 발생했습니다. 보관해야하거나 throw해야한다고 선언했습니다."
import java.io.*;
import java.util.regex.*;
class RegexMobileExtractor {
public static void main(String[] args) {
try {
Pattern p = Pattern.compile("(0|9)?[7-9][0-9]{9}");
PrintWriter pw = new PrintWriter("C:\\Users\\HP\\Desktop\\CODE\\JAVA_EX\\copy\\output.txt");
BufferedReader br = new BufferedReader(new FileReader("C:\\Users\\HP\\Desktop\\CODE\\JAVA_EX\\copy\\input.txt"));
//PrintWriter pw = new PrintWriter("output.txt");
//BufferedReader br = new BufferedReader(new FileReader("input.txt"));
String line = br.readLine();
while(line!= null) {
Matcher m = p.matcher(line);
while(m.find()) {
pw.println(m.group());
}
line = br.readLine();
}
pw.flush();
pw.close();
//br.close();
} catch (FileNotFoundException obj) {
System.out.println("errr occured");
}
}
}
그래서 'IOException'을 포착하면 여러 개의 캐치가있을 수 있습니다. –