On Tue, Mar 25, 2008 at 11:24 AM, Brian Eaton <[EMAIL PROTECTED]> wrote:
> I'm getting tired of writing str.indexOf("?") == -1. Does anyone know
> of a good library for parsing and modifying URLs, something with a
> compatible license?
I don't know of one myself, but for this trivial example why don't you just
use the URI class?
URI uri = URI.create("http://opensocial.org/request?foo=bar&bar=baz#blah");
String scheme = uri.getScheme(); // "http"
String host = uri.getAuthority(); // "opensocial.org"
String path = uri.getPath(); // "/request"
String query = uri.getQuery(); // "foo=bar&bar=baz"
String fragment = uri.getFragment(); // "blah"
I'm all for writing a url builder / extractor to get at individual query
parameters if there isn't a decent one we can borrow from elsewhere though.
--
~Kevin