private String encodeUri(String uri) {
    String newUri = "";
    StringTokenizer st = new StringTokenizer(uri, "/ ", true);
    while (st.hasMoreTokens()) {
      String tok = st.nextToken();
      if (tok.equals("/"))
        newUri += "/";
      else if (tok.equals(" "))
        newUri += "%20";
      else {
        newUri += URLEncoder.encode(tok);
        // For Java 1.4 you'll want to use this instead:
        // try { newUri += URLEncoder.encode( tok, "UTF-8" ); } catch (
        // java.io.UnsupportedEncodingException uee ) {}
      }
    }
    return newUri;
  }
URL-encodes everything between "/"-characters. Encodes spaces as '%20' instead of '+'.
selendroid-test-app/src/main/java/io/selendroid/testapp/server/NanoHTTPD.java