'Filerules' will not be null, because it is newly created, but that
doesn't mean that the file exists or that it is readable, etc.
Possibly try checking Filerules.exists(), Filerules.isFile(),
Filerules.canRead() ?

On Apr 6, 2005 6:58 PM, Raymond Hooker (rhooker) <[EMAIL PROTECTED]> wrote:
> Pardon the basic question but I cannot see what the problem is.  I was
> going through the SAX tutorials using Eclipse 3.0.2 and Java SDK
> 1.4.2_07.  Anyhow the following code gets throws
> java.lang.NullPointerException:
> 
>                 String rulesFile =
> fileDialog.getDirectory()+fileDialog.getFile();
>         // Use an instance of ourselves as the SAX event handler
>                   DefaultHandler handler = new Echo();
> 
>                         // Use the default (non-validating) parser
>                   SAXParserFactory factory =
> SAXParserFactory.newInstance();
>                   try {
>                     // Set up output stream
>                     out = new OutputStreamWriter(System.out, "UTF8");
> 
>                      // Parse the input
>                     File Filerules = new File(rulesFile);
>                     SAXParser saxParser = factory.newSAXParser();
>                     saxParser.parse( Filerules, handler );
> <----Exception occurs here
> 
>                         } catch (Throwable t) {
>                     t.printStackTrace();
>                   }
> 
> I verified that by a breakpoint that the time of exception Filerules was
> File object that is not null, and handler is a Echo instance.  Echo is
> class that extends DefaultHandler.  Echo has a number of methods to
> handle events like startDocument and startElement.  According to the
> JavaDoc, I don't believe that the parse method is supposed to throw a
> nullPointerException.  BTW the actual stack trace is:
> 
> java.lang.NullPointerException
>         at
> org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:691)
>         at org.apache.crimson.parser.Parser2.parse(Parser2.java:337)
>         at
> org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:448)
>         at javax.xml.parsers.SAXParser.parse(SAXParser.java:345)
>         at javax.xml.parsers.SAXParser.parse(SAXParser.java:281)
>         at Tree.rulesTree.main(rulesTree.java:103)
> 
> I have tried various file contents.
> 
> Ray
> 
> _______________________________________________
> Juglist mailing list
> [email protected]
> http://trijug.org/mailman/listinfo/juglist_trijug.org
> 


-- 
~akb
_________________
A. Kevin Baynes

_______________________________________________
Juglist mailing list
[email protected]
http://trijug.org/mailman/listinfo/juglist_trijug.org

Reply via email to