Here you can find the source of intToOneByteArray(int number)
Parameter | Description |
---|---|
number | int of the converted number |
public static byte[] intToOneByteArray(int number)
//package com.java2s; //License from project: Open Source License public class Main { /**/*from w w w . ja va2s . c o m*/ * Returns the int as a byte array with just one entry. * * @param number int of the converted number * @return byte array of size one with the int as a byte */ public static byte[] intToOneByteArray(int number) { return new byte[] { intToByte(number) }; } /** * Converts a int to a byte. * * @param number int number * @return byte of the int */ public static byte intToByte(int number) { if (number <= 255 && number > 0) return (byte) number; else return Byte.MIN_VALUE; } }