I am getting the error as "unreported exception ioexception; must be kept or declared to be thrown". It is the error in the path provided or in try - catch block.
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");
}
}
}