Java Convert via ByteBuffer intToBytes(int tagId)

Here you can find the source of intToBytes(int tagId)

Description

int To Bytes

License

Apache License

Declaration

public static byte[] intToBytes(int tagId) 

Method Source Code


//package com.java2s;
/*//w ww.j a va 2 s .  c  o m
 * Copyright (c) 2005 Chang Sau Sheong, Thomas Tarpin-Lyonnet.
 *
 * 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.
 */

import java.nio.ByteBuffer;

public class Main {
    public static byte[] intToBytes(int tagId) {
        ByteBuffer byteBuffer = ByteBuffer.allocate(1).putInt(tagId);
        byte[] bytes = byteBuffer.array();
        return bytes;
    }
}

Related

  1. intToBytes(final int integer)
  2. intToBytes(final int value)
  3. intToBytes(final int x)
  4. intToBytes(int i, byte[] backingStore, int offset)
  5. intToBytes(int n)
  6. intToBytesLE(int value)
  7. intToBytesWithLen(int x, int len)
  8. long2bytes(long num)
  9. longFromBytes(byte[] array)