• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Updating host and port informaiton for a given URL.

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 7134
1360
IntelliJ IDE jQuery Eclipse IDE Postgres Database Tomcat Server Chrome Google App Engine
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Creating a new URL object from an existing one seems like a simple thing to do:


 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic