Here you can find the source of unsignedInt2ByteLE(byte[] bytes, long value, int offset)
public static void unsignedInt2ByteLE(byte[] bytes, long value, int offset)
//package com.java2s; /*// w w w.j av a 2 s. c om * Copyright 2015-2017 GenerallyCloud.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ public class Main { public static void unsignedInt2ByteLE(byte[] bytes, long value, int offset) { checkLength(bytes, 4, offset); bytes[offset + 0] = (byte) ((value & 0xff)); bytes[offset + 1] = (byte) ((value >> 8 * 1) & 0xff); bytes[offset + 2] = (byte) ((value >> 8 * 2) & 0xff); bytes[offset + 3] = (byte) ((value >> 8 * 3)); } private static void checkLength(byte[] bytes, int length, int offset) { if (bytes == null) { throw new IllegalArgumentException("null"); } if (offset < 0) { throw new IllegalArgumentException("invalidate offset " + offset); } if (bytes.length - offset < length) { throw new IllegalArgumentException("invalidate length " + bytes.length); } } }