Here you can find the source of writeInt(ByteArrayOutputStream out, int val)
private static void writeInt(ByteArrayOutputStream out, int val) throws IOException
//package com.java2s; /****************************************************************************** * Copyright (c) 2004, 2006 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors://w ww . j ava 2s .c o m * IBM Corporation - initial API and implementation ****************************************************************************/ import java.io.ByteArrayOutputStream; import java.io.IOException; public class Main { private static void writeInt(ByteArrayOutputStream out, int val) throws IOException { // Little endian write out.write((byte) (val & 0xff)); out.write((byte) ((val >> 8) & 0xff)); out.write((byte) ((val >> 16) & 0xff)); out.write((byte) ((val >> 24) & 0xff)); } }