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 AppDynamics. Discover how AppDynamics steps in to upgrade your performance game and prevent your enterprise from these top 10 Java performance problems.


    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 AppDynamics. AppDynamics helps you gain the fundamentals behind application performance, and implement best practices so you can proactively analyze and act on performance problems as they arise, and more specifically with your Java applications. Start a Free Trial.

Topics:
java

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

{{ parent.tldr }}

{{ parent.urlSource.name }}