Java Byte to Int byte2int(final byte b)

Here you can find the source of byte2int(final byte b)

Description

Converts (unsigned) byte to int.

License

Open Source License

Parameter

Parameter Description
b byte to convert

Return

int value representing the given byte

Declaration

public static int byte2int(final byte b) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2012 GigaSpaces Technologies Ltd. All rights reserved
 *
 * 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.//  ww  w  .ja  v a  2  s.co m
 ******************************************************************************/

public class Main {
    /**
     * Converts (unsigned) byte to int.
     * 
     * @param b
     *            byte to convert
     * @return int value representing the given byte
     */
    public static int byte2int(final byte b) {
        int i = b;
        if (b < 0) {
            i = b & 0x7f + 128;
        }

        return i;
    }
}

Related

  1. byte2int(byte b)
  2. byte2int(byte b)
  3. Byte2Int(byte i)
  4. byte2integer(byte b)
  5. byte2integer(byte b)
  6. byteToInt(byte b)
  7. byteToInt(byte b)