New To Java - null

Hi,

looked through the tutorials, and some stuff online and still having trouble.

I've done a fair amount of modifying xml files with perl, and want to do the same thing with java.

I'm writing this at work, and we don't have the 1.5 jdk installed, so I can't use the Pattern and Match objects.

Here's some code I wrote:

package pack1;

import java.io.BufferedReader;

import java.io.FileNotFoundException;

import java.io.FileReader;

publicclass PlantTest{

/**

* @param args

* @throws Exception

*/

publicstaticvoid main(String[] args)throws Exception{

// get file to read from

java.io.File infile =new java.io.File("plant.xml");

FileReader infileReader =new FileReader(infile);

BufferedReader bInfile =new BufferedReader(infileReader);

//get basic file info

System.out.println("does the file exist? " + infile.exists());

System.out.println("file is located at: " + infile.getAbsolutePath());

System.out.println("file was last modified: " +new java.util.Date(infile.lastModified()));

// create a pattern

String match ="<COMMON>";

String line = bInfile.readLine();

while (line !=null){

//System.out.println(bInfile.readLine());

if (line.matches(match)){

System.out.println("match made: " + line);

}

}

bInfile.close();

infileReader.close();

}

}

I want the "match" object to be the equivalent of this in perl:

(I realize I don't have the output set up in the code above, I was going to add it later, for now I just want to make the match and print something on the console)

m/<COMMON>([^<]+)</COMMON>/i;

$common = $1;

print HTML"

Common Name: $common\n";

here's a snippet of xml:

<PLANT>

<COMMON>Bloodroot</COMMON>

<BOTANICAL>Sanguinaria canadensis</BOTANICAL>

<ZONE>4</ZONE>

<LIGHT>Mostly Shady</LIGHT>

<PRICE>$2.44</PRICE>

<AVAILABILITY>031599</AVAILABILITY>

</PLANT>

(I cribbed that xml from the w3c site)

thanks in advance,

bp

Message was edited by:

badperson

[3713 byte] By [badpersona] at [2007-11-26 23:16:32]
# 1
What version of java are you using? Regular expressions was added in JDK 1.4, and not 1.5Kaj
kajbja at 2007-7-10 14:17:14 > top of Java-index,Java Essentials,New To Java...
# 2
ouch. 1.3.1...That's here at work, I'm kind of nervous about downloading another jdk, will there be a conflict?
badpersona at 2007-7-10 14:17:14 > top of Java-index,Java Essentials,New To Java...
# 3
ouch. 1.3.1...That's here at work, I'm kind of nervous aboutdownloading another jdk, will there be a conflict?No, I have several versions installed. Kaj
kajbja at 2007-7-10 14:17:14 > top of Java-index,Java Essentials,New To Java...
# 4
ouch. 1.3.1...That's here at work, I'm kind of nervous aboutdownloading another jdk, will there be a conflict?Google for Jakarta ORO regex. It is about the same speed as Java regex and works well with JDK1.3.1 .
sabre150a at 2007-7-10 14:17:14 > top of Java-index,Java Essentials,New To Java...