Manipulating text file

I have a text file that look something like this:

[21/06/07] System DEBUG * BA_LOG_OUTPUT

System DEBUG Random text Random text

System DEBUG Random text Random text

System DEBUG Random text Random text

System DEBUG Random text Random text <?xml version=?.0?encoding=擴FT-8?>

<?xml version="1.0" encoding="UTF-8"?>

<note>

<to>Tove</to>

<from>Jani</from>

<heading>Reminder</heading>

<body>Don't forget me this weekend!</body>

</note>

[21/06/07] System DEBUG * BA_LOG_OUTPUT

System DEBUG Random text Random text

System DEBUG Random text Random text

System DEBUG Random text Random text

System DEBUG Random text Random text <?xml version=?.0?encoding=擴FT-8?>

<?xml version="1.0" encoding="UTF-8"?>

<note>

<to>Tony</to>

<from>James</from>

<heading>Reminder</heading>

<body>Don't forget me this weekend!</body>

</note>

[21/06/07] System DEBUG * BA_LOG_OUTPUT

System DEBUG Random text Random text

System DEBUG Random text Random text

System DEBUG Random text Random text

System DEBUG Random text Random text <?xml version=?.0?encoding=擴FT-8?>

<?xml version="1.0" encoding="UTF-8"?>

<note>

<to>Amy</to>

<from>Tobi</from>

<heading>Reminder</heading>

<body>Don't forget me this weekend!</body>

</note>

I am trying to read the file so that it picks the welled formed XML e.g:

<?xml version=?.0?encoding=擴FT-8?>

<?xml version="1.0" encoding="UTF-8"?>

<note>

<to>Tove</to>

<from>Jani</from>

<heading>Reminder</heading>

<body>Don't forget me this weekend!</body>

</note>

<?xml version=?.0?encoding=擴FT-8?>

<?xml version="1.0" encoding="UTF-8"?>

<note>

<to>Tony</to>

<from>James</from>

<heading>Reminder</heading>

<body>Don't forget me this weekend!</body>

</note>

<?xml version="1.0" encoding="UTF-8"?>

<note>

<to>Amy</to>

<from>Tobi</from>

<heading>Reminder</heading>

<body>Don't forget me this weekend!</body>

</note>

There is a pattern in the file, the line <?xml version=?.0?encoding=擴FT-8?>

Always start on the 4th line after BA_LOG_OUTPUT line

This is my code so far:

BufferedReader in =new BufferedReader(new FileReader(file));

String line =null;

Pattern p = Pattern.compile( 揃A_LOG_OUTPUT?);

StringBuffer sb =new StringBuffer();

while((line = in.readLing()) !=null){

Matcher m = p.matcher(line);

while(m.find()){

System.out.println( line );

}

}

How do I make it so it goes 4 line down so it can find the line <?xml version=?.0?encoding=擴FT-8?> and start reading the xml file?

[4065 byte] By [SDNJavaa] at [2007-11-27 8:24:50]
# 1
call readLine 4 times?But why aren't you looking for <?xml version="1.0" encoding="UTF-8"?> instead of BA_LOG_OUTPUT?
kajbja at 2007-7-12 20:14:02 > top of Java-index,Java Essentials,Java Programming...
# 2
This is because I am only interested in those XML after the BA_LOG_OUTPUT. There are other XML in the file which do not come after the BA_LOG_OUTPUT, those one are not of interest to me.
SDNJavaa at 2007-7-12 20:14:02 > top of Java-index,Java Essentials,Java Programming...
# 3
Where in the code do i call readLine() 4 times?
SDNJavaa at 2007-7-12 20:14:02 > top of Java-index,Java Essentials,Java Programming...
# 4
I am getting Unresolved compilation problem when i did:Pattern p2 = Pattern.compile( "<?xml version="1.0" encoding="UTF-8"?>" );
SDNJavaa at 2007-7-12 20:14:02 > top of Java-index,Java Essentials,Java Programming...
# 5
UsePattern p2 = Pattern.compile( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" );System.out.println(""+p2.pattern());Escape the quotes.
boneysekha at 2007-7-12 20:14:02 > top of Java-index,Java Essentials,Java Programming...