Java Byte Create toByte(final String strHexa)

Here you can find the source of toByte(final String strHexa)

Description

Converts a hexadecimal String to a byte

License

Open Source License

Parameter

Parameter Description
strHexa - String in a HexaDecimal

Return

String in HexaDecimal

Declaration

public static final byte toByte(final String strHexa) 

Method Source Code

//package com.java2s;
/*//from   w w  w  .  j  av  a  2s.c om
 *     @(#)HexaDecimalUtils.java   0.2 10/11/22
 *   Copyright (c) 2010 Felipe Priuli
 *
 *   This file is part of OpenSutils-Br4J.
 *
 *   OpenSutils-Br4J is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU Lesser General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, any later version.
 *
 *   OpenSutils-Br4J is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU Lesser General Public License for more details.
 *
 *   You should have received a copy of the GNU Lesser General Public License
 *   along with Foobar.  If not, see <http://www.gnu.org/licenses/>.
 */

public class Main {
    /**
     * Converts a hexadecimal String to a byte
     * @param strHexa - String in a HexaDecimal
     * @return String in HexaDecimal
     */
    public static final byte toByte(final String strHexa) {
        return ((byte) (Short.parseShort(strHexa.toUpperCase(), 16)));
    }
}

Related

  1. toByte(char hex)
  2. toByte(double x, double gamma)
  3. toByte(final byte[] buffer, final int offset)
  4. toByte(final int highNibble, final int lowNibble)
  5. toByte(final String bitString)
  6. toByte(final String value)
  7. toByte(float[][] in, byte[] out, float min, float max)
  8. toByte(int i)
  9. toByte(int n)