Path: csiph.com!goblin2!goblin.stu.neva.ru!news-hub.siol.net!news1.t-com.hr!.POSTED!not-for-mail From: Askfor Newsgroups: comp.lang.java.programmer Subject: number to byte[] Date: Sat, 17 Oct 2015 10:02:03 +0200 Organization: T-Com Lines: 6 Message-ID: NNTP-Posting-Host: 93-141-14-15.adsl.net.t-com.hr Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ls237.t-com.hr 1445068923 25131 93.141.14.15 (17 Oct 2015 08:02:03 GMT) X-Complaints-To: abuse@t-com.hr NNTP-Posting-Date: Sat, 17 Oct 2015 08:02:03 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 Xref: csiph.com comp.lang.java.programmer:32888 I am trying to get 4 byte[] representation of an integer, which might be 32 bit long. Obviously, I could AND with 255 and take byteValue(), then shift 8 times to the right and repeat the process 3 times. Is there any more elegant way ?