Java Byte Array Create toByteArrayFromPositiveInts(int[] inInts)

Here you can find the source of toByteArrayFromPositiveInts(int[] inInts)

Description

to Byte Array From Positive Ints

License

Open Source License

Declaration

public static byte[] toByteArrayFromPositiveInts(int[] inInts) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static byte[] toByteArrayFromPositiveInts(int[] inInts) {

        if (inInts == null) {
            return null;
        }/*from ww  w . j  av  a  2 s  .  c  o  m*/

        final byte[] theBytes = new byte[inInts.length];

        for (int i = 0; i < theBytes.length; i++) {

            theBytes[i] = positiveIntToByte(inInts[i]);
        }

        return theBytes;
    }

    public static byte positiveIntToByte(int inInt) {
        return (byte) (inInt - 128);
    }
}

Related

  1. toByteArray(String value)
  2. toByteArray(String[] anArray)
  3. toByteArray1D(int[][] d)
  4. toByteArrayBE(byte b)
  5. toByteArrayForPBE(char[] chars)
  6. toByteArrayFromString(String value, int radix)
  7. toByteArrayLE(int value)
  8. toByteArrayMM(int value)
  9. toByteArrayNoConversion(String textz)