matcher (java.lang.CharSequence) in Pattern cannot be applied to (java.io.BufferedReader)

I'm using Regex to match something in a text and I get each line with BufferedReader. Then I find the problem I can't solve:

    BufferedReader br=null;
    BufferedWriter bw=null;

    Pattern p=Pattern.compile(myRegex);

    try{
        FileReader fr=new FileReader(originTextUrl);
        FileWriter fw=new FileWriter(targetTextUrl);
        br=new BufferedReader(fr);
        bw=new BufferedWriter(fw);
        String s="";
        while ((s=br.readLine())!=null){

            Matcher m=p.matcher(br);

That's matcher (java.lang.CharSequence) in PatternĀ cannot be applied to (java.io.BufferedReader),I don't know how to solve this. Thanks for your answering!

Jon Skeet
people
quotationmark

Well as it says, you can't apply a Pattern to a BufferedReader - you have to read data from the reader, and then apply the pattern to that.

In this case, you're already reading the data - but then you're ignoring it! You want:

Matcher m = p.matcher(s);

I'd also strongly encourage you to use more descriptive variable names.

people

See more on this question at Stackoverflow