「ioexceptionは報告されていません;投棄する必要があります。これは、提供されたパスまたはtry-catchブロックのエラーです。「報告されていない例外ioexceptionが発生しています;保持する必要がある、またはスローすると宣言しなければなりません」
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'をキャッチすると、複数のキャッチが存在する可能性があります –