question: public static String toByteArray ( byte [ ] buf , int ofs , int len ) { StringBuffer sb = new StringBuffer ( ) ; for ( int i = ofs ; ( i < len ) && ( i < buf . length ) ; i ++ ) { sb . append ( '0' ) ; sb . append ( 'x' ) ; sb . append ( hexchars [ ( buf [ i ] & 0xF0 ) > > 4 ] ) ; sb . append ( hexchars [ buf [ i ] & 0x0F ] ) ; if ( ( ( i + 1 ) < len ) && ( ( i + 1 ) < buf . length ) ) { sb . append ( ',' ) ; } } return sb . toString ( ) ; }
target:  Returns a string which can be written to a Java source file as part of a static initializer for a byte array. Returns data in the format 0xAB, 0xCD, .... use like: javafile.print("byte[] data = {") javafile.print(Hexdump.toByteArray(data)); javafile.println("};");