Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Updating host and port informaiton for a given URL.

 
Jaya Lalla
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are there any common libraries that will update the host and port for a given URL - I do not want to str replace the url string or construct a new URL for an already formed URL String I would like to replace the hostname and port.

Thanks.
 
Devaka Cooray
ExamLab Creator
Marshal
Pie
Posts: 4426
255
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch

If you meant to replace the host and port of a String that contains a URL (just an address), why don't you just replace the host and port with String replacements? Even if there exists a library/API, that must be doing the same behind the scene. If you meant to change the host/port of a java.net.URL object, the only possible way is creating your own URLStreamHandler, which is not a good idea at all. The best thing what you can do is constructing a new URL object. Moving to the sockets forum.
 
Paul Clapham
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Creating a new URL object from an existing one seems like a simple thing to do:


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic