[jdom-interest] rewriting a file
Ian Lea
ian at digimem.net
Sun May 19 13:15:30 PDT 2002
The approach is fine. Is fn the same as outfile?
Do you have permission to write to outfile?
--
Ian.
ian at digimem.net
> brianw at knowledgextensions.com (Brian Wolf) wrote
>
> If I want to read a fiile in, do something and put it out in the same file,
> I try this:
>
> try{
> Document doc = builder.build(fn);
>
> // to something that changes the doc
>
> File outf = new File(outfile);
> PrintWriter out = new PrintWriter(new FileWriter(outf));
> XMLOutputter outputter = new XMLOutputter();
> outputter.setEncoding("ISO-8859-1" );
> outputter.output(doc, out);
> }
> catch (Exception ex) {
> System.out.println(ex.getMessage());}
>
>
> it won't allow access to the file to write out the changed version.
> Not sure I understand why because I thought builder dissociates from
> the file after its parsed intoa jdom? Whats the right approach here?
>
> Thanks
> Brian
>
>
>
----------------------------------------------------------------------
Searchable personal storage and archiving from http://www.digimem.net/
More information about the jdom-interest
mailing list