Ive successfully written code to parse a XML file from an internet URL. Now Im trying to do the same thing to a local file and im missing something simple (i think).
fin is declared as a FileReader object and initialized to null. When I parsed a file from the internet, I used the following code instead of the code in bold above:
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
/* Get the XMLReader of the SAXParser we created. */
XMLReader xr = sp.getXMLReader();
/* Create a new ContentHandler and apply it to the XML-Reader*/
ExampleHandler myExampleHandler = new ExampleHandler();
[b]fin = new FileReader(filename);
Thanks for the help!
You haven't said what the problem is that you are getting :) However InputSources expect to work with Streams rather than Readers so I would change your bold portion to read:
and of course change the definition of fin to be a FileInputStream
fin = new FileInputStream(filename);