Matcher doesn't find a pattern in the first line while reading with BufferedReader. Apart from the first line, it works perfectly well. I'm not sure if it's a bug, or I have done something wrong. Here's a piece of code that causes a problem. I've also tried methods matches() and lookingAt() but with no success.
bufferedReader = new BufferedReader(new InputStreamReader(url.openStream()));
Pattern p = Pattern.compile("^[0-9]");
String s;
Matcher m;
while((s = bufferedReader.readLine())!=null) {
m = p.matcher(s);
if(m.find())
System.out.println("Match found");
}
Aucun commentaire:
Enregistrer un commentaire