0

I'm trying to create an XML file. The path I'm trying the create the file in have some writing in Hebrew so it get all messed up. I've tried to decode it with the URLDecoder but for some reason it doesn't seem to work.

The code:

String decoded = URLDecoder.decode(path, "UTF-8");
StreamResult file = new StreamResult(new File(decoded + "/reports.xml"));
transformer.transform(source, file);

The exception:

javax.xml.transform.TransformerException: java.io.FileNotFoundException: C:\Users\%D7%9C%D7%99%D7%9E%D7%95%D7%93%D7%99%D7%9D\JAVA\reports.xml (The system cannot find the path specified)
    at org.apache.xalan.transformer.TransformerIdentityImpl.createResultContentHandler(TransformerIdentityImpl.java:297)
    at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:330)

path = C:\Users\עבודה

The code works in any other directory which name is only in English.

Arka
  • 19
  • 2
  • 1
    Please provide the original value of path, and the actual file name. – Mark Rotteveel Feb 05 '18 at 18:24
  • The fact that the decoded path still has percent-escapes in it suggests that it was URL-encoded twice before you received it (which was a mistake on the part of the sender). – VGR Feb 05 '18 at 20:35

0 Answers0