• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

URI - reverse host value

 
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

Java packages usually follow format of usuing reverse domain names e.g. developers working for a company www.google.com would put their classes in a package com.google.www.engine etc.... I am wondering if anybody has some code or knows of a library (I took a look at Apache commons but didnt find anything there) in where I might get some code that reverses the the host value of a URI so that it could be used as the name of a package.

Im sure its very simple to write but if its exists already that would be preferable.

Cheers,
John
 
Ranch Hand
Posts: 1209
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
not sure if there is one. But yeah as you said , you might want to write one and get done with it. May be its wierd and misplaced here but I cant even seem to recollect how to do this in java whereas it comes to me so naturally and spontaneously in python.

'.'.join(theUrl.split('.').reverse())

Java 1.5 tiger...yea great! ..but sometimes a pain
 
You don't know me, but I've been looking all over the world for. Thanks to the help from this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic