Number to byte array algorithm

If I have got a number, how can I convert it into a byte array? (The first byte represents the number from 1 to 127 (or 255) and so on)R. Hollenstein
[163 byte] By [robinhollensteina] at [2007-10-2 4:23:35]
# 1
Hi Robin,If you mean to convert an integer to base 256 then String.toHexString(i) will help. Otherwise repeatedly divide by 128 (or 256 or whatever) andadd the remainder to your array.Cheers,Peter
pbrockway2a at 2007-7-15 23:51:06 > top of Java-index,Other Topics,Algorithms...
# 2
http://onesearch.sun.com/search/onesearch/index.jsp?qt=integer+to+byte+array&subCat=&site=dev&dftab=&chooseCat=javaall&col=developer-forums
rkippena at 2007-7-15 23:51:06 > top of Java-index,Other Topics,Algorithms...