Rob,
I created the simple example, following your directions, and found that
on my system I can always delete file. Maby behaviour on your machinge
is depenedent on your code, that is keeping repherence to open file ????


Mit freundlichen Grüßen,
Best Regards,
River

-----Original Message-----
From: Sander Bos [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, August 13, 2003 3:49 PM
To: [EMAIL PROTECTED]
Subject: RE: Re[2]: XMLReader not releasing file reference


Dear Rob,

>    try {
> 
>             String uri             = "file:" + in.getAbsolutePath();
>             SAXParserFactory   spf = SAXParserFactory.newInstance();
>             SAXParser  sp          = spf.newSAXParser();
>             XMLReader  reader      = sp.getXMLReader();
>             reader.setContentHandler(new TestContentHandler());
>             reader.parse(uri);
> 
>         }
> 
>         catch (Exception e) {
>             System.out.println(in.delete());
>             //assertTrue (e.toString(), false);
>         }

Have you tried not letting Xerces opening the file, but doing it
yourself? (although I looked briefly at the Xerces code Peter McCracken
pointed to and it seems Xerces will always close the files, but there is
relatively a lot going on there).

So
   FileInputStream fis = null;
   try {
        ...
        fis = new FileInputStream(in);
        org.xml.sax.InputSource source = new InputSource(fis);
        source.setSystemId(uri);
        reader.parse(source);
   } catch (Exception e) {
        if (fis != null) {
          fis.close();
        }
        assertTrue(in.delete());
   }

or something along those lines (untested). Then you get to close the
file-stream 'yourself'.

Kind regards,

--Sander.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to