Java Serialize serializeIntLE(int value, byte[] outbuf, int offset)

Here you can find the source of serializeIntLE(int value, byte[] outbuf, int offset)

Description

serialize Int LE

License

Open Source License

Declaration

public static int serializeIntLE(int value, byte[] outbuf, int offset) 

Method Source Code


//package com.java2s;
/*// w ww  .  j a v  a2  s .  com
 *  PHEX - The pure-java Gnutella-servent.
 *  Copyright (C) 2001 - 2005 Phex Development Group
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 * 
 *  --- CVS Information ---
 *  $Id: IOUtil.java,v 1.36 2005/10/29 18:05:40 gregork Exp $
 */

import java.io.*;

public class Main {
    public static int serializeIntLE(int value, byte[] outbuf, int offset) {
        outbuf[offset++] = (byte) (value);
        outbuf[offset++] = (byte) (value >> 8);
        outbuf[offset++] = (byte) (value >> 16);
        outbuf[offset++] = (byte) (value >> 24);

        // Return next offset.
        return offset;
    }

    /**
     * Converts a int to a little-endian byte representation and writes it to the 
     * given stream.
     */
    public static void serializeIntLE(int value, OutputStream outStream) throws IOException {
        outStream.write((byte) (value));
        outStream.write((byte) (value >> 8));
        outStream.write((byte) (value >> 16));
        outStream.write((byte) (value >> 24));
    }
}

Related

  1. serializeFromString(final String pString)
  2. serializeGZip(T obj)
  3. serializeInt(int i)
  4. serializeInt2MinLE(int value)
  5. serializeInt2MinLE(int value)
  6. serializeJdk(Object obj)
  7. serializeMock(Object mock)
  8. serializeObject(B b)
  9. serializeObject(final Object object)