Over a million developers have joined DZone.
Platinum Partner

Convert an Int to a Byte Array

Convert an int into a byte array with this short code snippet.

· Java Zone

The Java Zone is brought to you in partnership with ZeroTurnaround. Check out this 8-step guide to see how you can increase your productivity by skipping slow application redeploys and by implementing application profiling, as you code!


    public static byte[] intToByteArray(int value) {
        byte[] b = new byte[4];
        for (int i = 0; i >> offset) & 0xFF);
        }
        return b;
    }


The Java Zone is brought to you in partnership with ZeroTurnaround. Discover how you can skip the build and redeploy process by using JRebel by ZeroTurnaround.

Topics:
java

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}