package GeneralDemos;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class BufferReaderDemo {
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
PrintWriter out = new PrintWriter("R:\\workspace Java\\textfiles\\output.txt");
Pattern p = Pattern.compile("(0/91)?[789][0-9]{9}");
BufferedReader br = new BufferedReader(new FileReader("R:\\workspace Java\\textfiles\\input.txt"));
String line = br.readLine();
while(line!=null){
Matcher m = p.matcher(line);
while(m.find() && m.group().equals(line)){
out.println(m.group());
}
line = br.readLine();
}
out.flush();
}
}
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class BufferReaderDemo {
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
PrintWriter out = new PrintWriter("R:\\workspace Java\\textfiles\\output.txt");
Pattern p = Pattern.compile("(0/91)?[789][0-9]{9}");
BufferedReader br = new BufferedReader(new FileReader("R:\\workspace Java\\textfiles\\input.txt"));
String line = br.readLine();
while(line!=null){
Matcher m = p.matcher(line);
while(m.find() && m.group().equals(line)){
out.println(m.group());
}
line = br.readLine();
}
out.flush();
}
}
No comments:
Post a Comment