Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think that @BalusC has nailed the direct problem in your code. I'd just like to point out some other issuse</p> <p>The <code>dir.toURI().toASCIIString()</code> and <code>URLEncoder.encoder(fn, "UTF-8").toString()</code> expressions actually do rather different things.</p> <ul> <li><p>The first one, encodes the URI as a string, applying the URI encoding rules according to the URI grammar. So for example, a '/' in the path component will not be encoded but a '/' in the query or fragment components will be encoded as %2F.</p></li> <li><p>The second one, encodes the <code>fn</code> String applying the encoding rules without reference to the content of the string.</p></li> </ul> <p>The <code>File(URI)</code> constructor's mapping from a file URI to a File is <a href="http://java.sun.com/javase/6/docs/api/java/io/File.html#File(java.net.URI)" rel="nofollow noreferrer">system dependent and undocumented</a>. I'm a bit surprised that it decodes the <code>%2F</code>, but it does what it does, and @BalusC explains why. The take-away is that it is potentially problematic to use a mechanism ("file:" URIs) that are explicitly system dependent.</p> <p>Finally, it is wrong to combine those URI component strings like that. It should be either</p> <pre><code>URI uri = new URI( dir.toURI().toString() + URLEncoder.encoder(fn, "UTF-8").toString(); </code></pre> <p>or</p> <pre><code>URI uri = new URI( dir.toURI().toASCIIString() + URLEncoder.encoder(fn, "ASCII").toString()); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload