Biblioteka transformatorów dostarczana z Javą konwertuje spacje w ścieżkach do% 20

Oto aplikacja testowa, która wypisuje pliki XML.

Dlaczego przestrzenie na mojej ścieżce są przekształcane na%20?

public class XmlTest
{
    public static void main(String[] args)
    {
        String filename = "C:\\New Folder\\test.xml";
        try {
            DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
            DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
            Document doc = docBuilder.newDocument();
            TransformerFactory transformerFactory = TransformerFactory.newInstance();
            Transformer transformer = transformerFactory.newTransformer();
            transformer.setOutputProperty(OutputKeys.INDENT, "yes");
            transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
            DOMSource source = new DOMSource(doc);

            File xmlFile = new File(filename);
            if (xmlFile.exists())
            {
                xmlFile.delete();
            }
            StreamResult result = new StreamResult(xmlFile);
            transformer.transform(source, result);

        }
        catch (ParserConfigurationException ex)
        {
            ex.printStackTrace();
        }
        catch (TransformerException tfe)
        {
            tfe.printStackTrace();
        }
    }
}

Ślad stosu:

java.io.FileNotFoundException: C:\New%20Folder\test.xml (The system cannot find the path specified)
    at java.io.FileOutputStream.open(Native Method)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:179)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:70)
    at org.apache.xalan.transformer.TransformerIdentityImpl.createResultContentHandler(TransformerIdentityImpl.java:287)
    at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:330)
    at avm.trans.xml.XmlTest.main(XmlTest.java:52)

questionAnswers(3)

yourAnswerToTheQuestion