Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6681543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:36:08+00:00 2026-05-26T04:36:08+00:00

String arg=http://www.example.com/user.php?id=<URLRequest Method=’GetByUID’ />; java.net.URI uri = new java.net.URI( arg ); java.awt.Desktop desktop =

  • 0
String arg="http://www.example.com/user.php?id=<URLRequest Method='GetByUID' />";
java.net.URI uri = new java.net.URI( arg );
java.awt.Desktop desktop = java.awt.Desktop.getDesktop();
desktop.browse( uri );

I want to open the given link in default browser with the above code but it says the url is invalid…i tried escaping characters like ‘ also but its not working.
If i replace String arg=”www.google.com”; then there is no problem and I am able to open google.com.
Please help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T04:36:08+00:00Added an answer on May 26, 2026 at 4:36 am

    Your string contains characters that aren’t valid in a URI, per RFC 2396. You need to properly encode the query parameters. Many utilities support that, like the standard URLEncoder (lower level), JAX-RS UriBuilder, Spring UriUtils, Apache HttpClient URLEncodedUtils and so on.

    Edit: Oh, and the URI class can handle it, too, but you have to use a different constructor:

    URI uri = new URI("http", "foo.com", null, "a=<some garbage>&b= |{$0m3 m0r3 garbage}| &c=imokay", null);
    System.out.println(uri);
    

    Outputs:

    http://foo.com?a=%3Csome%20garbage%3E&b=%20%7C%7B$0m3%20m0r3%20garbage%7D%7C%20&c=imokay
    

    which, while ugly, is the correct representation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose you have a Java method void foobar(int id, String ... args) and want
Hey SO community, I saw here: http://www.mustap.com/phpzone_post_203_setter-and-getter an argument for using a type of
I'm trying to make a working program from this example: http://msdn.microsoft.com/en-us/library/ms741870.aspx . I think
Here's the code snippet: public static void main (String[]arg) { char ca = 'a'
I have following code public class TEST { public static void main(String arg[]){ try
string [] files = new string[2]; files[0] = ThinkFarAhead.Example.Settings.Configuration_Local.xml; files[1] = ThinkFarAhead.Example.Settings.Configuration_Global.xml; //Resharper complains
Similar to this post http://feedproxy.google.com/~r/cadence/community/blogs/fv/~3/IvdCIla8_Es/extending-multiple-when-subtypes-simultaneously.aspx I want to make a macro that does loop
My spring-context file is shown below. <beans xmlns=http://www.springframework.org/schema/beans xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xmlns:aop=http://www.springframework.org/schema/aop xmlns:jee=http://www.springframework.org/schema/jee xmlns:jms=http://www.springframework.org/schema/jms xmlns:lang=http://www.springframework.org/schema/lang xmlns:tx=http://www.springframework.org/schema/tx
I have a question in Java how can I check if an image http
String s = ; for(i=0;i<....){ s = some Assignment; } or for(i=0;i<..){ String s

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.