1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
static final Pattern PATTERN = Pattern.compile("<monTag:message .*? />");
static Matcher matcher;
{
try {
File file = new File("c:\\Temp\\file.txt");
BufferedReader reader = new BufferedReader(new FileReader(file));
String line = "", oldtext = "";
int i = 0 ;
while ((line = reader.readLine()) != null) {
matcher = PATTERN.matcher(line);
if(matcher.find()){
//transmettre la ligne:
System.out.println ("trouvé : " +i + " -- DEB ="+ matcher.start() + " -- FIN =" +matcher.end());
System.out.println (line);
if(matcher.find(matcher.end()));{
System.out.println ("trouvé : " +i + " -- DEB ="+ matcher.start() + " -- FIN =" +matcher.end());
System.out.println (line);}
i++;
} |