public static String reverseIP(String addr){
  Pattern p=Pattern.compile("^(\\d+)\\.(\\d+)\\.(\\d+)\\.(\\d+)$");
  Matcher m=p.matcher(addr);
  return m.replaceAll("$4.$3.$2.$1");
}

public static String reverseIP ( String addr ) { Pattern p = Pattern . compile ( "^(\\d+)\\.(\\d+)\\.(\\d+)\\.(\\d+)$" ) ; Matcher m = p . matcher ( addr ) ; return m . replaceAll ( "$4.$3.$2.$1" ) ; }
reverse the order of the octets in a given ipv4 address .
