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

