My Java standalone application gets a URL (which points to a file) from the user and I need to hit it and download it. The problem I am facing is that I am not able to encod
I develop a library that serves this purpose: galimatias. It parses URL the same way web browsers do. That is, if a URL works in a browser, it will be correctly parsed by galimatias.
In this case:
// Parse
io.mola.galimatias.URL.parse(
"http://search.barnesandnoble.com/booksearch/first book.pdf"
).toString()
Will give you: http://search.barnesandnoble.com/booksearch/first%20book.pdf
. Of course this is the simplest case, but it'll work with anything, way beyond java.net.URI
.
You can check it out at: https://github.com/smola/galimatias