imaginary family values presents

yesh omrim

a blog that reclines to the left



11 May 2004

To continue with yesterday’s saga of the dain-bramaged Java library API:

It turns out that someURI = new URI, null) does not, after all, convert URLs to URIs appropriately: when the path information gets converted to and then from a string, special characters get double-escaped. The proper incantation, it turns out, is someURI = URI.create(someURL.toString());.

At least, I think that’s the proper incantation. It works for my test directory, but nothing in the documentation for URL.toString() guarantees that the method will output a string in the format that URI.create(String) is documented to read.

Why should I be forced to explicitly convert this information to and from a string format, anyway? I thought I was programming in Java because Java’s type system lets me concentrate on the abstractions in a system (locations and indicators) and doesn’t force me to think about other module authors’ implementation decisions (string formats). [No, you’re programming in Java because nobody wanted to hire you as a Perl programmer. —ed.] Oh. All right, then.