public class DottedQuad { /** * display an IP as a dotted quad xxx.xxx.xxx.xxx */ public static String dottedQuad ( int ip ) { StringBuffer sb = new StringBuffer( 15 ); for ( int shift=24; shift >0; shift-=8 ) { // process 3 bytes, from high order byte down. sb.append( Integer.toString( (ip >>> shift) & 0xff )); sb.append('.'); } sb.append( Integer.toString( ip & 0xff ) ); return sb.toString(); } /** * test harness * * @param args not used */ public static void main ( String[] args ) { out.println( dottedQuad( 0x01ff0010 ) ); } }