Advertisement

08.23.2005 at 08:32AM PDT, ID: 21536921
[x]
Attachment Details

Transformer :: Cannot delete the file transformed

Asked by msl22 in Programming Languages

Tags: cannot, delete, file, streamresult, transformer

Hi,

I use a Transformer to generate an xml file in a local directory. Then I broadcast the file over the system and finally I clean up the local directory. My problem, is that the transformer keeps an handle on the generated file... So I'm not able to delete the file, until the JVM is stopped...

I'm looking for any work around.

//Here is a sample to test the problem

public void testTransform() throws Exception{
        Document doc = BasicDom.parseXmlFile("c:/test.xml", false);

        TransformerFactory tFactory = TransformerFactory.newInstance();
        Transformer transformer = tFactory.newTransformer();
        DOMSource source = new DOMSource(doc);
        StreamResult result = new StreamResult("C:/result.xml");
        transformer.transform(source, result);
        if ( new File("c:/result.xml").delete()) {
            System.out.println("ca marche!");
        }
    }



Thanks,

Marie-Soleil

Start Free Trial
[+][-]08.25.2005 at 06:37PM PDT, ID: 14757956

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Programming Languages
Tags: cannot, delete, file, streamresult, transformer
Sign Up Now!
Solution Provided By: dbkruger
Participating Experts: 1
Solution Grade: A
 
 
[+][-]08.26.2005 at 07:22AM PDT, ID: 14761134

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.26.2005 at 07:33PM PDT, ID: 14766524

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32