Re: Deleting programmaticaly xul files
Phalip Julien <[email protected]> Tue, 15 Feb 2005 00:01:33 +0100 (CET)
| Newsgroups | gmane.comp.java.luxor-xul.user |
|---|---|
| Message-ID | <[email protected]> |
--0-1112784435-1108422093=:73465 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Apparently the problem was not from Luxor. I forgot to close explicitly the fileOutputStream I used to create the fi= le. As I didn't keep any reference of this object I thought it would have= been closed automatically when the garbage collector killed it. =20 So, forget about my "in.close()" patch. =20 Cheers. Martin van den Bemt <[email protected]> wrote: Your try catch doesn't really add anything. Add a finally, so the in.close is always executed in case of an error.. Don't know if it solves anything, but it at least is an improvement. Mvgr, Martin sgfdgf ryejt wrote: > Hi all, >=20 > My application dynamically generates xul files and copy them in the=20 > chrome/startup directory. Then I use Luxor to render them in a java=20 > environment. But once the rendering is done, I would like to delete=20 > these xul files. >=20 > To do so: >=20 > File file =3D new file ("chrome/startup/myfile.xul"); > boolean b =3D file.delete(); >=20 > However, 90% (yes, not 100%) of the times, I cannot delete them and b =3D= =3D=20 > false. >=20 > I suspect, the xul file might be used my a thread or something. However= =20 > I can delete it manually from the windows explorer... >=20 > I tried, in vain: >=20 > while (!file.delete()) {} which loops forever... >=20 > I also tried to modify the method: >=20 > XulLoader.load(String name) { > { > try > { > T.debug( "loading xul file " + name ); > InputStream in =3D _loader.getResourceAsStream( name ); > SAXBuilder builder =3D new SAXBuilder(); > Document doc =3D builder.build( in ); > Element xul =3D doc.getRootElement(); > createElements( null, xul ); > T.debug( "xul file " + name + " successfully loaded" ); > // Here's my modification... > try { > in.close(); > } > catch (IOException ex) { > } > } > catch( JDOMException jex ) > { > Xul.Error.XUL_PARSING_EXCEPTION( name, jex ); > } > } >=20 > ...didn't work either.... >=20 > Would you have an idea of how to fix this? >=20 > Cheers, >=20 > Julien >=20 >=20 > -----------------------------------------------------------------------= - > D=E9couvrez le nouveau Yahoo! Mail : 250 Mo d'espace de stockage pour v= os=20 > mails ! > Cr=E9ez votre Yahoo! Mail=20 >=20 >=20 ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=3D6595&alloc_id=3D14396&op=3Dclick _______________________________________________ luxor-xul-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/luxor-xul-user =09 --------------------------------- D=E9couvrez le nouveau Yahoo! Mail : 250 Mo d'espace de stockage pour vo= s mails ! Cr=E9ez votre Yahoo! Mail --0-1112784435-1108422093=:73465 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable <DIV>Apparently the problem was not from Luxor.</DIV> <DIV>I forgot to close explicitly the fileOutputStream I used to create t= he file. As I didn't keep any reference of this object I thought it would= have been closed automatically when the garbage collector killed it.</DI= V> <DIV> </DIV> <DIV>So, forget about my "in.close()" patch.</DIV> <DIV> </DIV> <DIV>Cheers.<BR><BR><B><I>Martin van den Bemt <[email protected]></I>= </B> wrote:</DIV> <BLOCKQUOTE class=3Dreplbq style=3D"PADDING-LEFT: 5px; MARGIN-LEFT: 5px; = BORDER-LEFT: #1010ff 2px solid">Your try catch doesn't really add anythin= g.<BR>Add a finally, so the in.close is always executed in case of an err= or..<BR>Don't know if it solves anything, but it at least is an improveme= nt.<BR><BR>Mvgr,<BR>Martin<BR><BR>sgfdgf ryejt wrote:<BR>> Hi all,<BR>= > <BR>> My application dynamically generates xul files and copy the= m in the <BR>> chrome/startup directory. Then I use Luxor to render th= em in a java <BR>> environment. But once the rendering is done, I woul= d like to delete <BR>> these xul files.<BR>> <BR>> To do so:<BR>= > <BR>> File file =3D new file ("chrome/startup/myfile.xul");<BR>&g= t; boolean b =3D file.delete();<BR>> <BR>> However, 90% (yes, not 1= 00%) of the times, I cannot delete them and b =3D=3D <BR>> false.<BR>&= gt; <BR>> I suspect, the xul file might be used my a thread or somethi= ng. However <BR>> I can delete it manually from the windows explorer...<BR>> <BR>> I tried, in vain:<BR>> <BR>> = while (!file.delete()) {} which loops forever...<BR>> <BR>> I also = tried to modify the method:<BR>> <BR>> XulLoader.load(String name) = {<BR>> {<BR>> try<BR>> {<BR>> T.debug( "loading xul file " + = name );<BR>> InputStream in =3D _loader.getResourceAsStream( name );<B= R>> SAXBuilder builder =3D new SAXBuilder();<BR>> Document doc =3D = builder.build( in );<BR>> Element xul =3D doc.getRootElement();<BR>>= ; createElements( null, xul );<BR>> T.debug( "xul file " + name + " su= ccessfully loaded" );<BR>> // Here's my modification...<BR>> try {<= BR>> in.close();<BR>> }<BR>> catch (IOException ex) {<BR>> }<= BR>> }<BR>> catch( JDOMException jex )<BR>> {<BR>> Xul.Error.= XUL_PARSING_EXCEPTION( name, jex );<BR>> }<BR>> }<BR>> <BR>> = ...didn't work either....<BR>> <BR>> Would you have an idea of how = to fix this?<BR>> <BR>> Cheers,<BR>> <BR>> Julien<BR>> <BR>> <BR>> ---------------------------------------= ---------------------------------<BR>> D=E9couvrez le nouveau Yahoo! M= ail : 250 Mo d'espace de stockage pour vos <BR>> mails !<BR>> Cr=E9= ez votre Yahoo! Mail <BR>> <HTTP: evt=3D"25917/*http://fr.rd.yahoo.com= /mail_fr/mail_campaigns/splash/taglines_250/default/*http://fr.promotions= .yahoo.com/mail/creer28.html" fr.rd.yahoo.com *http: taglines mail><BR>&g= t; <BR><BR><BR>-------------------------------------------------------<BR= >SF email is sponsored by - The IT Product Guide<BR>Read honest & can= did reviews on hundreds of IT Products from real users.<BR>Discover which= products truly live up to the hype. Start reading now.<BR>http://ads.osd= n.com/?ad_id=3D6595&alloc_id=3D14396&op=3Dclick<BR>______________= _________________________________<BR>luxor-xul-user mailing list<BR>luxor= [email protected]<BR>https://lists.sourceforge.net/lists/li= stinfo/luxor-xul-user<BR></BLOCKQUOTE><p> <hr size=3D1>=20 D=E9couvrez le nouveau Yahoo! Mail : <font color=3D"red">250 Mo d'espace<= /font> de stockage pour vos mails !<br><a href=3D"http://fr.rd.yahoo.com/= mail/taglines/*http://fr.rd.yahoo.com/evt=3D25917/*http://fr.rd.yahoo.com= /mail_fr/mail_campaigns/splash/taglines_250/default/*http://fr.promotions= .yahoo.com/mail/creer28.html">Cr=E9ez votre Yahoo! Mail</a> --0-1112784435-1108422093=:73465-- ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click