[jdom-interest] rewriting a file

Brian Wolf brianw at knowledgextensions.com
Sat May 18 13:14:44 PDT 2002


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


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://jdom.org/pipermail/jdom-interest/attachments/20020518/c73a4702/attachment.htm


More information about the jdom-interest mailing list