permaculture playing cards*
The moose likes Sockets and Internet Protocols and the fly likes Updating host and port informaiton for a given URL. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Updating host and port informaiton for a given URL." Watch "Updating host and port informaiton for a given URL." New topic
Author

Updating host and port informaiton for a given URL.

Jaya Lalla
Greenhorn

Joined: May 22, 2012
Posts: 3
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
Saloon Keeper

Joined: Jul 29, 2008
Posts: 3019
    
  35

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.


Author of ExamLab ExamLab - a free SCJP / OCPJP exam simulator
What would SCJP exam questions look like? -- Home -- Twitter -- How to Ask a Question
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Creating a new URL object from an existing one seems like a simple thing to do:


 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Updating host and port informaiton for a given URL.
 
Similar Threads
How to configure SSL in RAD 7
allow requests from a certain url with remote host filter
How to get exact exception type
ConnectionException under Win ME
Doing ftp from a JSP