Here you can find the source of serializeInt(int i)
public static byte[] serializeInt(int i)
//package com.java2s; //License from project: Open Source License import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; import java.io.IOException; public class Main { public static byte[] serializeInt(int i) { ByteArrayOutputStream bos = new ByteArrayOutputStream(4); DataOutputStream dos = new DataOutputStream(bos); try {/* w w w. ja va 2s . co m*/ dos.writeInt(i); } catch (IOException e) { throw new RuntimeException(e); } return bos.toByteArray(); } }